Skip to content

Instantly share code, notes, and snippets.

@j1n3l0
Created January 14, 2020 16:14
Show Gist options
  • Save j1n3l0/56877ea6f98ce0ae5276c79bbb133d94 to your computer and use it in GitHub Desktop.
Save j1n3l0/56877ea6f98ce0ae5276c79bbb133d94 to your computer and use it in GitHub Desktop.
'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