starts writing tests for tasks, fix errors in auth middleware and tasks methods

This commit is contained in:
Matteo Pagliazzi
2015-12-03 17:48:32 +01:00
parent 62708d4365
commit 506609cc29
4 changed files with 67 additions and 4 deletions

View File

@@ -0,0 +1,31 @@
import {
generateUser,
requester,
translate as t,
} from '../../../../helpers/api-integration.helper';
import { v4 as generateRandomUserName } from 'uuid';
import { each } from 'lodash';
describe('POST /tasks', () => {
let user;
let api;
before(() => {
return generateUser().then((generatedUser) => {
user = generatedUser;
api = requester(user);
});
});
context('checks "type" is present and a valid value', () => {
it('returns an error if req.body.type is absent', () => {
expect(api.post('/tasks', {
notType: 'habit',
})).to.eventually.be.rejected.and.eql({
code: 400,
error: 'BadRequest',
message: t('invalidReqParams'),
});
});
});
});