mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 06:07:21 +01:00
starts writing tests for tasks, fix errors in auth middleware and tasks methods
This commit is contained in:
31
test/api/v3/integration/tasks/POST-create_task.test.js
Normal file
31
test/api/v3/integration/tasks/POST-create_task.test.js
Normal 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'),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user