@omegabigdata/honoplay-api-helper-node
Version:
94 lines (79 loc) • 2.96 kB
JavaScript
const should = require("should");
const sinon = require("sinon");
const app = require("../index").Tenant;
describe("#TenantTest", () => {
describe("- getTenant", () => {
it("should getTenant tenantId mandatory", () => {
should(() => app.getTenant(null)).throwError("Missing Parameters");
});
it("should getTenant tenantId numeric", () => {
should(() => app.getTenant("5")).throwError("Must be positive numbers");
});
it("should getTenant tenantId positive number", () => {
should(() => app.getTenant(-1)).throwError("Must be positive numbers");
});
it("should method called success callback", () => {
let success = sinon.spy();
app.getTenant(1, success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.getTenant(53, () => {}, error);
should(error.called).be.true;
});
});
describe("- getTenants", () => {
it("should getTenants skip and take positive numbers", () => {
should(() => app.getTenants(-1, -1)).throwError(
"Values must be positive"
);
});
it("should getTenants skip and take numeric", () => {
should(() => app.getTenants("a", "b")).throwError(
"Values must be numeric"
);
});
it("should method called success callback", () => {
let success = sinon.spy();
app.getTenants(1, 1, success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.getTenants(50, 50, () => {}, error);
should(error.called).be.true;
});
});
describe("- postTenant", () => {
it("should PostTenant tenant Model mandatory", () => {
should.throws(app.postTenant);
should(() => app.postTenant()).throwError("Missing Parameters");
});
it("should method called success callback", () => {
let success = sinon.spy();
app.postTenant({}, success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.postTenant({}, () => {}, error);
should(error.called).be.true;
});
});
describe("- putTenant", () => {
it("should Put Tenant tenant Model mandatory", () => {
should(() => app.putTenant()).throwError("Missing Parameters");
});
it("should method called success callback", () => {
let success = sinon.spy();
app.putTenant({}, success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.putTenant({}, () => {}, error);
should(error.called).be.true;
});
});
});