Last active
May 8, 2018 23:43
-
-
Save adover/b2bb22ae085a6ebcc23ff53fe5402258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const sinon = require('sinon'); | |
const chai = require('chai'); | |
const expect = chai.expect; | |
const SomeController = require('../../app/controllers/SomeController') | |
describe('SomeController', () => { | |
let stub; | |
beforeEach(() => { | |
stub = sinon.stub(SomeController, 'doAPICall'); | |
}); | |
describe('addLeave', () => { | |
it('Should be a function', () => { | |
expect(SomeController.addLeave).to.be.a('function'); | |
}); | |
it('Should return false if no employeeID', async () => { | |
const result = await BambooController.addLeave(); | |
expect(result).to.be.false; | |
}); | |
it('Should return an array of objects', async () => { | |
stub.resolves('10'); | |
const result = await SomeController.addLeave('5'); | |
expect(result).to.equal('success'); | |
}); | |
it('Should return false after being rejected', async () => { | |
stub.rejects(); | |
const result = await SomeController.addLeave('5'); | |
expect(result).to.throw(); | |
}); | |
}); | |
afterEach(() => { | |
stub.restore(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment