mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
tests(api): Convert tests to use new api user methods
This commit is contained in:
@@ -1,22 +1,20 @@
|
||||
import {
|
||||
generateUser,
|
||||
requester,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
|
||||
describe('PUT /user/tasks/:id', () => {
|
||||
let api, user, task;
|
||||
let user, task;
|
||||
|
||||
beforeEach(() => {
|
||||
return generateUser().then((_user) => {
|
||||
user = _user;
|
||||
api = requester(user);
|
||||
task = user.todos[0];
|
||||
});
|
||||
});
|
||||
|
||||
it('does not update the id of the task', () => {
|
||||
return api.put(`/user/tasks/${task.id}`, {
|
||||
return user.put(`/user/tasks/${task.id}`, {
|
||||
id: 'some-thing',
|
||||
}).then((updatedTask) => {
|
||||
expect(updatedTask.id).to.eql(task.id);
|
||||
@@ -25,7 +23,7 @@ describe('PUT /user/tasks/:id', () => {
|
||||
});
|
||||
|
||||
it('does not update the type of the task', () => {
|
||||
return api.put(`/user/tasks/${task.id}`, {
|
||||
return user.put(`/user/tasks/${task.id}`, {
|
||||
type: 'habit',
|
||||
}).then((updatedTask) => {
|
||||
expect(updatedTask.type).to.eql(task.type);
|
||||
@@ -34,7 +32,7 @@ describe('PUT /user/tasks/:id', () => {
|
||||
});
|
||||
|
||||
it('updates text, attribute, priority, value and notes', () => {
|
||||
return api.put(`/user/tasks/${task.id}`, {
|
||||
return user.put(`/user/tasks/${task.id}`, {
|
||||
text: 'new text',
|
||||
notes: 'new notes',
|
||||
value: 10000,
|
||||
@@ -50,7 +48,7 @@ describe('PUT /user/tasks/:id', () => {
|
||||
});
|
||||
|
||||
it('returns an error if the task does not exist', () => {
|
||||
return expect(api.put('/user/tasks/task-id-that-does-not-exist'))
|
||||
return expect(user.put('/user/tasks/task-id-that-does-not-exist'))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: 'Task not found.',
|
||||
@@ -60,7 +58,7 @@ describe('PUT /user/tasks/:id', () => {
|
||||
it('does not update another user\'s task', () => {
|
||||
return expect(generateUser().then((otherUser) => {
|
||||
let otherUsersTask = otherUser.todos[0];
|
||||
return api.put(`/user/tasks/${otherUsersTask._id}`, {
|
||||
return user.put(`/user/tasks/${otherUsersTask._id}`, {
|
||||
name: 'some name',
|
||||
});
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
|
||||
Reference in New Issue
Block a user