UNPKG

@omegabigdata/honoplay-api-helper-node

Version:
93 lines (77 loc) 2.83 kB
const should = require("should"); const sinon = require("sinon"); const app = require("../index").Trainer; describe("#Trainer Test", () => { describe("- Get Trainers", () => { it("should getTrainers skip and take positive numbers", () => { should(() => app.getTrainers(-1, -1)).throwError( "Values must be positive" ); }); it("should getTrainers skip and take numeric", () => { should(() => app.getTrainers("1", "2")).throwError( "Values must be numeric" ); }); it("should method called success callback", () => { let success = sinon.spy(); app.getTrainers(1, 1, success, () => {}); should(success.called).be.true; }); it("should method called error callback when throw error", () => { let error = sinon.spy(); app.getTrainers(5, 5, () => {}, error); should(error.called).be.true; }); }); describe("- Get Trainer", () => { it("should getTrainer must not null ", () => { should(() => app.getTrainer()).throwError("Missing Parameters"); }); it("should getTrainer must be greater than zero ", () => { should(() => app.getTrainer(0)).throwError( "Value must be greater than zero" ); }); it("should method called success callback", () => { let success = sinon.spy(); app.getTrainer(1, success, () => {}); should(success.called).be.true; }); it("should method called error callback when throw error", () => { let error = sinon.spy(); app.getTrainer(5, () => {}, error); should(error.called).be.true; }); }); describe("- Put Trainer", () => { it("should Put Trainer trainer Model mandatory", () => { should(() => app.putTrainer()).throwError("Missing Parameters"); }); it("should method called success callback", () => { let success = sinon.spy(); app.putTrainer({}, success, () => {}); should(success.called).be.true; }); it("should method called error callback when throw error", () => { let error = sinon.spy(); app.putTrainer({}, () => {}, error); should(error.called).be.true; }); }); describe("- Post Trainer", () => { it("should Post Trainer trainer Model mandatory", () => { should(() => app.postTrainer()).throwError("Missing Parameters"); }); it("should method called success callback", () => { let success = sinon.spy(); app.postTrainer({}, success, () => {}); should(success.called).be.true; }); it("should method called error callback when throw error", () => { let error = sinon.spy(); app.postTrainer({}, () => {}, error); should(error.called).be.true; }); }); });