UNPKG

@jesseditson/dnsimple

Version:

A Node.JS client for the DNSimple API.

86 lines (85 loc) 4.28 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("registrant", () => { const accountId = 1010; describe("#checkRegistrantChange", () => { it("produces a registrant change", () => __awaiter(void 0, void 0, void 0, function* () { nock("https://api.dnsimple.com") .post("/v2/1010/registrar/registrant_changes/check") .reply((0, util_1.readFixtureAt)("checkRegistrantChange/success.http")); const response = yield dnsimple.registrar.checkRegistrantChange(accountId, { contact_id: 101, domain_id: 101, }); const data = response.data; expect(data.domain_id).toBe(101); expect(data.contact_id).toBe(101); expect(data.extended_attributes).toEqual([]); expect(data.registry_owner_change).toBe(true); })); }); describe("#createRegistrantChange", () => { it("produces a registrant change", () => __awaiter(void 0, void 0, void 0, function* () { nock("https://api.dnsimple.com") .post("/v2/1010/registrar/registrant_changes") .reply((0, util_1.readFixtureAt)("createRegistrantChange/success.http")); const response = yield dnsimple.registrar.createRegistrantChange(accountId, { contact_id: 101, domain_id: 101, extended_attributes: {}, }); const data = response.data; expect(data.id).toBe(101); expect(data.account_id).toBe(101); expect(data.domain_id).toBe(101); expect(data.contact_id).toBe(101); expect(data.state).toBe("new"); expect(data.extended_attributes).toEqual({}); expect(data.registry_owner_change).toBe(true); expect(data.irt_lock_lifted_by).toBe(null); expect(data.created_at).toBe("2017-02-03T17:43:22Z"); expect(data.created_at).toBe("2017-02-03T17:43:22Z"); })); }); describe("#deleteRegistrantChange", () => { it("deletes the registrant change", () => __awaiter(void 0, void 0, void 0, function* () { const scope = nock("https://api.dnsimple.com") .delete("/v2/1010/registrar/registrant_changes/101") .reply((0, util_1.readFixtureAt)("deleteRegistrantChange/success.http")); yield dnsimple.registrar.deleteRegistrantChange(accountId, 101); expect(scope.isDone()).toBeTruthy(); })); }); describe("#getRegistrantChange", () => { it("returns the registrant change", () => __awaiter(void 0, void 0, void 0, function* () { nock("https://api.dnsimple.com") .get("/v2/1010/registrar/registrant_changes/101") .reply((0, util_1.readFixtureAt)("getRegistrantChange/success.http")); const response = yield dnsimple.registrar.getRegistrantChange(accountId, 101); expect(response.data).toEqual({ id: 101, account_id: 101, domain_id: 101, contact_id: 101, state: "new", extended_attributes: {}, registry_owner_change: true, irt_lock_lifted_by: null, created_at: "2017-02-03T17:43:22Z", updated_at: "2017-02-03T17:43:22Z", }); })); }); });