@jesseditson/dnsimple
Version:
A Node.JS client for the DNSimple API.
41 lines (40 loc) • 2.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 util_1 = require("./util");
const dnsimple = (0, util_1.createTestClient)();
describe("identity", () => {
describe("#whoami when authenticated as account", () => {
it("produces an account", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.get("/v2/whoami")
.reply((0, util_1.readFixtureAt)("whoami/success-account.http"));
const response = yield dnsimple.identity.whoami();
expect(response.data.user).toBe(null);
const account = response.data.account;
expect(account.id).toEqual(1);
expect(account.email).toEqual("example-account@example.com");
}));
});
describe("#whoami when authenticated as user", () => {
it("produces a user", () => __awaiter(void 0, void 0, void 0, function* () {
nock("https://api.dnsimple.com")
.get("/v2/whoami")
.reply((0, util_1.readFixtureAt)("whoami/success-user.http"));
const response = yield dnsimple.identity.whoami();
expect(response.data.account).toBe(null);
const user = response.data.user;
expect(user.id).toEqual(1);
expect(user.email).toEqual("example-user@example.com");
}));
});
});
;