UNPKG

@jesseditson/dnsimple

Version:

A Node.JS client for the DNSimple API.

83 lines (82 loc) 4.67 kB
"use strict"; 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 util_1 = require("./util"); const dnsimple = (0, util_1.createTestClient)(); describe("whois privacy", () => { const accountId = 1010; const domainId = "example.com"; describe("#getWhoisPrivacy", () => { it("produces a whois privacy", () => __awaiter(void 0, void 0, void 0, function* () { nock("https://api.dnsimple.com") .get("/v2/1010/registrar/domains/example.com/whois_privacy") .reply((0, util_1.readFixtureAt)("getWhoisPrivacy/success.http")); const response = yield dnsimple.registrar.getWhoisPrivacy(accountId, domainId); const whoisPrivacy = response.data; expect(whoisPrivacy.id).toBe(1); expect(whoisPrivacy.domain_id).toBe(2); expect(whoisPrivacy.expires_on).toBe("2017-02-13"); expect(whoisPrivacy.enabled).toBe(true); expect(whoisPrivacy.created_at).toBe("2016-02-13T14:34:50Z"); expect(whoisPrivacy.updated_at).toBe("2016-02-13T14:34:52Z"); })); }); describe("#enableWhoisPrivacy", () => { describe("when whois privacy is already purchased", () => { it("produces a whois privacy", () => __awaiter(void 0, void 0, void 0, function* () { nock("https://api.dnsimple.com") .put("/v2/1010/registrar/domains/example.com/whois_privacy") .reply((0, util_1.readFixtureAt)("enableWhoisPrivacy/success.http")); const response = yield dnsimple.registrar.enableWhoisPrivacy(accountId, domainId); const whoisPrivacy = response.data; expect(whoisPrivacy.id).toBe(1); expect(whoisPrivacy.domain_id).toBe(2); })); }); describe("when whois privacy is newly purchased", () => { it("produces a whois privacy", () => __awaiter(void 0, void 0, void 0, function* () { nock("https://api.dnsimple.com") .put("/v2/1010/registrar/domains/example.com/whois_privacy") .reply((0, util_1.readFixtureAt)("enableWhoisPrivacy/created.http")); const response = yield dnsimple.registrar.enableWhoisPrivacy(accountId, domainId); const whoisPrivacy = response.data; expect(whoisPrivacy.id).toBe(1); expect(whoisPrivacy.domain_id).toBe(2); })); }); }); describe("#disableWhoisPrivacy", () => { it("produces a whois privacy", () => __awaiter(void 0, void 0, void 0, function* () { nock("https://api.dnsimple.com") .delete("/v2/1010/registrar/domains/example.com/whois_privacy") .reply((0, util_1.readFixtureAt)("disableWhoisPrivacy/success.http")); const response = yield dnsimple.registrar.disableWhoisPrivacy(accountId, domainId); const whoisPrivacy = response.data; expect(whoisPrivacy.id).toBe(1); expect(whoisPrivacy.domain_id).toBe(2); })); }); describe("#renewWhoisPrivacy", () => { it("produces a whois privacy renewal", () => __awaiter(void 0, void 0, void 0, function* () { nock("https://api.dnsimple.com") .post("/v2/1010/registrar/domains/example.com/whois_privacy/renewals") .reply((0, util_1.readFixtureAt)("renewWhoisPrivacy/success.http")); const response = yield dnsimple.registrar.renewWhoisPrivacy(accountId, domainId); const whoisPrivacyRenewal = response.data; expect(whoisPrivacyRenewal.id).toBe(1); expect(whoisPrivacyRenewal.domain_id).toBe(100); expect(whoisPrivacyRenewal.whois_privacy_id).toBe(999); expect(whoisPrivacyRenewal.state).toBe("new"); expect(whoisPrivacyRenewal.enabled).toBe(true); })); }); });