@omegabigdata/honoplay-api-helper-node
Version:
70 lines (59 loc) • 2.22 kB
JavaScript
const should = require("should");
const sinon = require("sinon");
// const moxios = require("moxios");
// const removeModule = require("clear-module");
const app = require("../index").AdminUser;
describe("#AdminUserTest", () => {
describe("#getAuthenticate", () => {
it("should getAuthenticate username and password mandatory", () => {
should.throws(app.getAuthenticate);
should(() => app.getAuthenticate()).throwError("Missing Parameters");
});
it("should method called success callback", () => {
let success = sinon.spy();
app.getAuthenticate(
{ email: "test", password: "test" },
success,
() => {}
);
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.getAuthenticate(null, () => {}, error);
should(error.called).be.true;
});
});
describe("#postRegister", () => {
it("should postRegister username and password mandatory", () => {
should.throws(app.postRegister);
should(() => app.postRegister()).throwError("Missing Parameters");
});
it("should method called success callback", () => {
let success = sinon.spy();
app.postRegister(null, success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.postRegister(null, () => {}, error);
should(error.called).be.true;
});
});
describe("#postRenewToken", () => {
it("should postRenewToken token mandatory", () => {
should.throws(app.postRenewToken);
should(() => app.postRenewToken()).throwError("Missing Parameters");
});
it("should method called success callback", () => {
let success = sinon.spy();
app.postRenewToken("token", success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.postRenewToken(null, () => {}, error);
should(error.called).be.true;
});
});
});