mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +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('GET /user/tasks/:id', () => {
|
||||
let api, user, task;
|
||||
let user, task;
|
||||
|
||||
beforeEach(() => {
|
||||
return generateUser().then((_user) => {
|
||||
user = _user;
|
||||
task = user.todos[0];
|
||||
api = requester(user);
|
||||
});
|
||||
});
|
||||
|
||||
it('gets a task', () => {
|
||||
return api.get(`/user/tasks/${task.id}`).then((foundTask) => {
|
||||
return user.get(`/user/tasks/${task.id}`).then((foundTask) => {
|
||||
expect(foundTask.id).to.eql(task.id);
|
||||
expect(foundTask.text).to.eql(task.text);
|
||||
expect(foundTask.notes).to.eql(task.notes);
|
||||
@@ -26,7 +24,7 @@ describe('GET /user/tasks/:id', () => {
|
||||
});
|
||||
|
||||
it('returns an error if the task does not exist', () => {
|
||||
return expect(api.get('/user/tasks/task-that-does-not-exist'))
|
||||
return expect(user.get('/user/tasks/task-that-does-not-exist'))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: t('messageTaskNotFound'),
|
||||
@@ -36,7 +34,8 @@ describe('GET /user/tasks/:id', () => {
|
||||
it('does not get another user\'s task', () => {
|
||||
return expect(generateUser().then((otherUser) => {
|
||||
let otherUsersTask = otherUser.todos[0];
|
||||
return api.get(`/user/tasks/${otherUsersTask.id}`);
|
||||
|
||||
return user.get(`/user/tasks/${otherUsersTask.id}`);
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
text: t('messageTaskNotFound'),
|
||||
|
||||
Reference in New Issue
Block a user