Created
July 8, 2020 13:10
-
-
Save kianaditya/cb8bf55c7b43e6a2a116462c2c87625c 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 expect = require('chai').expect | |
const queries = require('../../../src/models/queries') | |
const { show } = require('../../../src/controllers/users') | |
describe('Users Controller', () => { | |
const user = {} | |
describe('GET User', () => { | |
it('should use show action and send response', async () => { | |
const getUserStub = sinon.stub(queries, 'getUser').resolves(user) | |
let resSpy = sinon.spy() | |
const req = { | |
user: { | |
email: '[email protected]', | |
}, | |
} | |
const res = { | |
status: sinon.stub().returns({ send: resSpy }), | |
} | |
await show(req, res) | |
expect(getUserStub.calledOnce).to.equal(true) | |
expect(resSpy.calledOnce).to.equal(true) | |
expect(resSpy.calledWith(user)).to.equal(true) | |
getUserStub.restore() | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment