misc fixes and improvements, starts adding route tests

This commit is contained in:
Matteo Pagliazzi
2015-11-18 12:36:13 +01:00
parent b5adf9f19b
commit 65a8d2e255
7 changed files with 24 additions and 35 deletions
+10 -27
View File
@@ -1,30 +1,13 @@
import {
generateRes,
generateReq,
generateNext,
} from '../../../../helpers/api-unit.helper';
import { requester } from '../../../../helpers/api-integration.helper';
import notFoundHandler from '../../../../../website/src/middlewares/api-v3/notFound';
describe('notFound Middleware', () => {
it('returns a 404 error when the resource is not found', () => {
let request = requester().get('/api/v3/dummy-url');
import { NotFound } from '../../../../../website/src/libs/api-v3/errors';
describe('notFoundHandler', () => {
let res, req, next;
beforeEach(() => {
res = generateRes();
req = generateReq();
next = generateNext();
});
xit('sends NotFound error if the resource isn\'t found', () => {
expect(res.status).to.be.calledOnce;
expect(res.json).to.be.calledOnce;
expect(res.status).to.be.calledWith(404);
expect(res.json).to.be.calledWith({
error: 'NotFound',
message: 'Not found.',
});
});
return expect(request)
.to.eventually.be.rejected.and.eql({
error: "NotFound",
message: "Not found.",
});
});
});