add example apidoc comments, add notFound middleware

This commit is contained in:
Matteo Pagliazzi
2015-11-17 16:48:50 +01:00
parent 61948e1ca5
commit aa1b046cf2
9 changed files with 102 additions and 21 deletions

View File

@@ -0,0 +1,32 @@
import {
generateRes,
generateReq,
generateNext,
} from '../../../../helpers/api-unit.helper';
import notFoundHandler from '../../../../../website/src/middlewares/api-v3/notFound';
import { NotFound } from '../../../../../website/src/libs/api-v3/errors';
describe('notFoundHandler', () => {
let res, req, next;
beforeEach(() => {
res = generateRes();
req = generateReq();
next = generateNext();
sandbox.stub(logger, 'error');
});
it('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.',
});
});
});