UNPKG

@omegabigdata/honoplay-api-helper-node

Version:
93 lines (78 loc) 2.96 kB
const should = require("should"); const sinon = require("sinon"); const app = require("../index").Trainee; describe("#Trainee Test", () => { describe("- Post Trainee", () => { it("should Trainee Post trainee Model mandatory", () => { should(() => app.postTrainee()).throwError("Invalid Trainee Model"); }); it("should method called success callback", () => { let success = sinon.spy(); app.postTrainee({}, success, () => {}); should(success.called).be.true; }); it("should method called error callback when throw error", () => { let error = sinon.spy(); app.postTrainee({}, () => {}, error); should(error.called).be.true; }); }); describe("- Put Trainee", () => { it("should Trainee Post trainee Model mandatory", () => { should(() => app.putTrainee()).throwError("Invalid Trainee Model"); }); it("should method called success callback", () => { let success = sinon.spy(); app.putTrainee({}, success, () => {}); should(success.called).be.true; }); it("should method called error callback when throw error", () => { let error = sinon.spy(); app.putTrainee({}, () => {}, error); should(error.called).be.true; }); }); describe("- getTraninee", () => { it("should getTrainee traineeId mandatory", () => { should(() => app.getTrainee()).throwError("Missing Parameters"); }); it("should getTrainee traineeId numeric", () => { should(() => app.getTrainee("5")).throwError("must be number"); }); it("should getTrainee traineeId must be positive number", () => { should(() => app.getTrainee(-1)).throwError("must be positive number"); }); it("should method called success callback", () => { let success = sinon.spy(); app.putTrainee({}, success, () => {}); should(success.called).be.true; }); it("should method called error callback when throw error", () => { let error = sinon.spy(); app.putTrainee({}, () => {}, error); should(error.called).be.true; }); }); describe("- getTrainees", () => { it("should getTrainees skip and take positive numbers", () => { should(() => app.getTrainees(-1, -1)).throwError( "Values must be positive" ); }); it("should getTrainees skip and take numeric", () => { should(() => app.getTrainees("1", "2")).throwError( "Values must be numeric" ); }); it("should method called success callback", () => { let success = sinon.spy(); app.getTrainees(1, 1, success, () => {}); should(success.called).be.true; }); it("should method called error callback when throw error", () => { let error = sinon.spy(); app.getTrainees(5, 5, () => {}, error); should(error.called).be.true; }); }); });