Created
January 14, 2020 16:14
-
-
Save j1n3l0/56877ea6f98ce0ae5276c79bbb133d94 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
'use strict'; | |
const { expect } = require('chai'); | |
const middleware = async (req, res) => { | |
if (!req.query.jobId) { | |
throw Error('Missing requirement (jobId)'); | |
} | |
return res.status(200).json({ message: 'OK' }); | |
}; | |
describe('Controller: /process-applications', () => { | |
describe('Given a Bad Request', () => { | |
it('should throw an Error', async () => { | |
// NOTE: would have been nice if this worked | |
// expect(() => await middleware(req, res)).to.throw(); | |
try { | |
const req = { query: {} }; | |
const res = {}; | |
await middleware(req, res); | |
} | |
catch (err) { | |
expect(err).to.have.property('message', 'Missing requirement (jobId)'); | |
} | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment