mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
tests(api): Convert tests to use new api user methods
This commit is contained in:
@@ -1,33 +1,31 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
|
||||
describe('POST /user/tasks', () => {
|
||||
|
||||
let api, user;
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
return generateUser().then((_user) => {
|
||||
user = _user;
|
||||
api = requester(user);
|
||||
});
|
||||
});
|
||||
|
||||
it('creates a task', () => {
|
||||
return api.post('/user/tasks').then((task) => {
|
||||
return user.post('/user/tasks').then((task) => {
|
||||
expect(task.id).to.exist;
|
||||
});
|
||||
});
|
||||
|
||||
it('creates a habit by default', () => {
|
||||
return expect(api.post('/user/tasks'))
|
||||
return expect(user.post('/user/tasks'))
|
||||
.to.eventually.have.property('type', 'habit');
|
||||
});
|
||||
|
||||
it('creates a task with specified values', () => {
|
||||
return api.post('/user/tasks', {
|
||||
return user.post('/user/tasks', {
|
||||
type: 'daily',
|
||||
text: 'My task',
|
||||
notes: 'My notes',
|
||||
@@ -43,7 +41,7 @@ describe('POST /user/tasks', () => {
|
||||
it('does not create a task with an id that already exists', () => {
|
||||
let todo = user.todos[0];
|
||||
|
||||
return expect(api.post('/user/tasks', {
|
||||
return expect(user.post('/user/tasks', {
|
||||
id: todo.id,
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 409,
|
||||
@@ -52,7 +50,7 @@ describe('POST /user/tasks', () => {
|
||||
});
|
||||
|
||||
xit('TODO: no error is thrown - throws a 500 validation error if invalid type is posted', () => {
|
||||
return expect(api.post('/user/tasks', {
|
||||
return expect(user.post('/user/tasks', {
|
||||
type: 'not-valid',
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 500,
|
||||
@@ -61,7 +59,7 @@ describe('POST /user/tasks', () => {
|
||||
});
|
||||
|
||||
xit('TODO: no error is thrown - throws a 500 validation error if invalid data is posted', () => {
|
||||
return expect(api.post('/user/tasks', {
|
||||
return expect(user.post('/user/tasks', {
|
||||
frequency: 'not-valid',
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 500,
|
||||
|
||||
Reference in New Issue
Block a user