add example apidoc comments, add notFound middleware
This commit is contained in:
@@ -88,7 +88,7 @@ describe('errorHandler', () => {
|
||||
errorHandler(error, req, res, next);
|
||||
|
||||
expect(logger.error).to.be.calledOnce;
|
||||
expect(logger.error).to.be.calledWith(error.stack, {
|
||||
expect(logger.error).to.be.calledWithExactly(error.stack, {
|
||||
originalUrl: req.originalUrl,
|
||||
headers: req.headers,
|
||||
body: req.body,
|
||||
|
||||
@@ -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.',
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user