@omegabigdata/honoplay-api-helper-node
Version:
83 lines (67 loc) • 2.51 kB
JavaScript
const should = require("should");
const sinon = require("sinon");
const app = require("../index").Question;
describe("# Question", () => {
describe("- Put Question", () => {
it("should Put Question Question Model mandatory", () => {
should(() => app.putQuestion()).throwError("Missing Parameters");
});
it("should method called success callback", () => {
let success = sinon.spy();
app.putQuestion({}, success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.putQuestion({}, () => {}, error);
should(error.called).be.true;
});
});
describe("- Post Question", () => {
it("should Post Question Question Model mandatory", () => {
should(() => app.postQuestion()).throwError("Missing Parameters");
});
it("should method called success callback", () => {
let success = sinon.spy();
app.postQuestion({}, success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.postQuestion({}, () => {}, error);
should(error.called).be.true;
});
});
describe("- Get Questions", () => {
it("should getQuestions skip and take positive numbers", () => {
should(() => app.getQuestions(-1, -1)).throwError(
"Values must be positive"
);
});
it("should method called success callback", () => {
let success = sinon.spy();
app.getQuestions(1, 1, success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.getQuestions(5, 5, () => {}, error);
should(error.called).be.true;
});
});
describe("- Get Question", () => {
it("should getQuestion must not null ", () => {
should(() => app.getQuestion()).throwError("Missing Parameters");
});
it("should method called success callback", () => {
let success = sinon.spy();
app.getQuestion(1, success, () => {});
should(success.called).be.true;
});
it("should method called error callback when throw error", () => {
let error = sinon.spy();
app.getQuestion(5, () => {}, error);
should(error.called).be.true;
});
});
});