@jesseditson/dnsimple
Version:
A Node.JS client for the DNSimple API.
90 lines (89 loc) • 4.69 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 util_1 = require("./util");
const dnsimple = (0, util_1.createTestClient)();
describe("domains", () => {
describe("#initiatePush", () => {
const accountId = 1010;
const domainId = "example.com";
const attributes = { new_account_email: "jim@example.com" };
it("builds the correct request", () => __awaiter(void 0, void 0, void 0, function* () {
const scope = nock("https://api.dnsimple.com")
.post("/v2/1010/domains/example.com/pushes", attributes)
.reply((0, util_1.readFixtureAt)("initiatePush/success.http"));
yield dnsimple.domains.initiatePush(accountId, domainId, attributes);
expect(scope.isDone()).toBeTruthy();
}));
it("produces a push result", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.post("/v2/1010/domains/example.com/pushes")
.reply((0, util_1.readFixtureAt)("initiatePush/success.http"));
const response = yield dnsimple.domains.initiatePush(accountId, domainId, attributes);
const push = response.data;
expect(push.id).toBe(1);
expect(push.domain_id).toBe(100);
expect(push.contact_id).toBe(null);
expect(push.account_id).toBe(2020);
expect(push.created_at).toBe("2016-08-11T10:16:03Z");
expect(push.updated_at).toBe("2016-08-11T10:16:03Z");
expect(push.accepted_at).toBe(null);
}));
});
describe("#listPushes", () => {
const accountId = 1010;
it("produces an pushes list", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.get("/v2/1010/pushes")
.reply((0, util_1.readFixtureAt)("listPushes/success.http"));
const response = yield dnsimple.domains.listPushes(accountId);
expect(response.data.length).toBe(2);
}));
});
describe("#acceptPush", () => {
const accountId = 1010;
const pushId = 200;
const attributes = { contact_id: 1 };
it("builds the correct request", () => __awaiter(void 0, void 0, void 0, function* () {
const scope = nock("https://api.dnsimple.com")
.post("/v2/1010/pushes/200", attributes)
.reply((0, util_1.readFixtureAt)("acceptPush/success.http"));
yield dnsimple.domains.acceptPush(accountId, pushId, attributes);
expect(scope.isDone()).toBeTruthy();
}));
it("produces nothing", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.post("/v2/1010/pushes/200")
.reply((0, util_1.readFixtureAt)("acceptPush/success.http"));
const response = yield dnsimple.domains.acceptPush(accountId, pushId, attributes);
expect(response).toEqual({});
}));
});
describe("#rejectPush", () => {
const accountId = 1010;
const pushId = 200;
it("builds the correct request", () => __awaiter(void 0, void 0, void 0, function* () {
const scope = nock("https://api.dnsimple.com")
.delete("/v2/1010/pushes/200")
.reply((0, util_1.readFixtureAt)("rejectPush/success.http"));
yield dnsimple.domains.rejectPush(accountId, pushId);
expect(scope.isDone()).toBeTruthy();
}));
it("produces nothing", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.delete("/v2/1010/pushes/200")
.reply((0, util_1.readFixtureAt)("rejectPush/success.http"));
const response = yield dnsimple.domains.rejectPush(accountId, pushId);
expect(response).toEqual({});
}));
});
});
;