@jesseditson/dnsimple
Version:
A Node.JS client for the DNSimple API.
54 lines (53 loc) • 3.11 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const nock = require("nock");
const main_1 = require("../lib/main");
const util_1 = require("./util");
const dnsimple = (0, util_1.createTestClient)();
describe("registrar auto renewal", () => {
const accountId = 1010;
const domainId = "example.com";
describe("#enableDomainAutoRenewal", () => {
it("produces an empty result", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.put("/v2/1010/registrar/domains/example.com/auto_renewal")
.reply((0, util_1.readFixtureAt)("enableDomainAutoRenewal/success.http"));
const response = yield dnsimple.registrar.enableDomainAutoRenewal(accountId, domainId);
expect(response).toEqual({});
}));
describe("when the domain does not exist", () => {
it("results in an error", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.put("/v2/1010/registrar/domains/example.com/auto_renewal")
.reply((0, util_1.readFixtureAt)("notfound-domain.http"));
yield expect(dnsimple.registrar.enableDomainAutoRenewal(accountId, domainId)).rejects.toThrow(main_1.NotFoundError);
}));
});
});
describe("#disableDomainAutoRenewal", () => {
it("produces an empty result", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.delete("/v2/1010/registrar/domains/example.com/auto_renewal")
.reply((0, util_1.readFixtureAt)("disableDomainAutoRenewal/success.http"));
const response = yield dnsimple.registrar.disableDomainAutoRenewal(accountId, domainId);
expect(response).toEqual({});
}));
describe("when the domain does not exist", () => {
it("results in an error", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.delete("/v2/1010/registrar/domains/example.com/auto_renewal")
.reply((0, util_1.readFixtureAt)("notfound-domain.http"));
yield expect(dnsimple.registrar.disableDomainAutoRenewal(accountId, domainId)).rejects.toThrow(main_1.NotFoundError);
}));
});
});
});
;