lint: Correct linting errors in api v3 tests
This commit is contained in:
@@ -36,7 +36,7 @@ describe('GET /groups/:groupId/chat', () => {
|
||||
});
|
||||
|
||||
it('returns Guild chat', () => {
|
||||
return user.get('/groups/' + group._id + '/chat')
|
||||
return user.get(`/groups/${group._id}/chat`)
|
||||
.then((getChat) => {
|
||||
expect(getChat).to.eql(group.chat);
|
||||
});
|
||||
@@ -67,7 +67,7 @@ describe('GET /groups/:groupId/chat', () => {
|
||||
|
||||
it('returns error if user is not member of requested private group', () => {
|
||||
return expect(
|
||||
user.get('/groups/' + group._id + '/chat')
|
||||
user.get(`/groups/${group._id}/chat`)
|
||||
)
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
import _ from 'lodash';
|
||||
import { find } from 'lodash';
|
||||
|
||||
describe('POST /chat/:chatId/flag', () => {
|
||||
let user;
|
||||
@@ -66,7 +66,7 @@ describe('POST /chat/:chatId/flag', () => {
|
||||
return user.get(`/groups/${group._id}`);
|
||||
})
|
||||
.then((updatedGroup) => {
|
||||
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
||||
let messageToCheck = find(updatedGroup.chat, {id: message.id});
|
||||
expect(messageToCheck.flags[user._id]).to.equal(true);
|
||||
});
|
||||
});
|
||||
@@ -89,7 +89,7 @@ describe('POST /chat/:chatId/flag', () => {
|
||||
return user.get(`/groups/${group._id}`);
|
||||
})
|
||||
.then((updatedGroup) => {
|
||||
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
||||
let messageToCheck = find(updatedGroup.chat, {id: message.id});
|
||||
expect(messageToCheck.flags[secondUser._id]).to.equal(true);
|
||||
expect(messageToCheck.flagCount).to.equal(5);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
import _ from 'lodash';
|
||||
import { find } from 'lodash';
|
||||
|
||||
describe('POST /chat/:chatId/like', () => {
|
||||
let user;
|
||||
@@ -65,7 +65,7 @@ describe('POST /chat/:chatId/like', () => {
|
||||
return user.get(`/groups/${group._id}`);
|
||||
})
|
||||
.then((updatedGroup) => {
|
||||
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
||||
let messageToCheck = find(updatedGroup.chat, {id: message.id});
|
||||
expect(messageToCheck.likes[user._id]).to.equal(true);
|
||||
});
|
||||
});
|
||||
@@ -89,7 +89,7 @@ describe('POST /chat/:chatId/like', () => {
|
||||
return user.get(`/groups/${group._id}`);
|
||||
})
|
||||
.then((updatedGroup) => {
|
||||
let messageToCheck = _.find(updatedGroup.chat, {id: message.id});
|
||||
let messageToCheck = find(updatedGroup.chat, {id: message.id});
|
||||
expect(messageToCheck.likes[user._id]).to.equal(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('POST /group', () => {
|
||||
return expect(
|
||||
user.post('/groups', {
|
||||
name: groupName,
|
||||
type: groupType
|
||||
type: groupType,
|
||||
})
|
||||
)
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
@@ -38,7 +38,7 @@ describe('POST /group', () => {
|
||||
return generateUser({balance: 1}).then((generatedUser) => {
|
||||
return generatedUser.post('/groups', {
|
||||
name: groupName,
|
||||
type: groupType
|
||||
type: groupType,
|
||||
});
|
||||
})
|
||||
.then((result) => {
|
||||
@@ -54,13 +54,12 @@ describe('POST /group', () => {
|
||||
let groupName = 'Test Private Guild';
|
||||
let groupType = 'guild';
|
||||
let groupPrivacy = 'private';
|
||||
let tmpUser;
|
||||
|
||||
return generateUser({balance: 1}).then((generatedUser) => {
|
||||
return generatedUser.post('/groups', {
|
||||
name: groupName,
|
||||
type: groupType,
|
||||
privacy: groupPrivacy
|
||||
privacy: groupPrivacy,
|
||||
});
|
||||
})
|
||||
.then((result) => {
|
||||
@@ -80,7 +79,7 @@ describe('POST /group', () => {
|
||||
|
||||
return user.post('/groups', {
|
||||
name: groupName,
|
||||
type: groupType
|
||||
type: groupType,
|
||||
})
|
||||
.then((result) => {
|
||||
expect(result._id).to.exist;
|
||||
@@ -98,7 +97,7 @@ describe('POST /group', () => {
|
||||
tmpUser = generatedUser;
|
||||
return tmpUser.post('/groups', {
|
||||
name: groupName,
|
||||
type: groupType
|
||||
type: groupType,
|
||||
});
|
||||
})
|
||||
.then(() => {
|
||||
|
||||
@@ -12,13 +12,11 @@ describe('PUT /tags/:tagId', () => {
|
||||
});
|
||||
|
||||
it('updates a tag given it\'s id', () => {
|
||||
let length;
|
||||
|
||||
return user.post('/tags', {name: 'Tag 1'})
|
||||
.then((createdTag) => {
|
||||
return user.put(`/tags/${createdTag._id}`, {
|
||||
name: 'Tag updated',
|
||||
ignored: true
|
||||
ignored: true,
|
||||
});
|
||||
})
|
||||
.then((updatedTag) => {
|
||||
|
||||
@@ -25,9 +25,9 @@ describe('DELETE /tasks/:id', () => {
|
||||
});
|
||||
|
||||
it('deletes a user\'s task', () => {
|
||||
return user.del('/tasks/' + task._id)
|
||||
return user.del(`/tasks/${task._id}`)
|
||||
.then(() => {
|
||||
return expect(user.get('/tasks/' + task._id)).to.eventually.be.rejected.and.eql({
|
||||
return expect(user.get(`/tasks/${task._id}`)).to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('taskNotFound'),
|
||||
@@ -54,7 +54,7 @@ describe('DELETE /tasks/:id', () => {
|
||||
});
|
||||
})
|
||||
.then((task2) => {
|
||||
return expect(user.del('/tasks/' + task2._id)).to.eventually.be.rejected.and.eql({
|
||||
return expect(user.del(`/tasks/${task2._id}`)).to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('taskNotFound'),
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
import Q from 'q';
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('GET /tasks/:id', () => {
|
||||
});
|
||||
|
||||
it('gets specified task', () => {
|
||||
return user.get('/tasks/' + task._id)
|
||||
return user.get(`/tasks/${task._id}`)
|
||||
.then((getTask) => {
|
||||
expect(getTask).to.eql(task);
|
||||
});
|
||||
@@ -38,7 +38,9 @@ describe('GET /tasks/:id', () => {
|
||||
|
||||
context('task cannot be accessed', () => {
|
||||
it('cannot get a non-existant task', () => {
|
||||
return expect(user.get('/tasks/' + generateUUID())).to.eventually.be.rejected.and.eql({
|
||||
let dummyId = generateUUID();
|
||||
|
||||
return expect(user.get(`/tasks/${dummyId}`)).to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('taskNotFound'),
|
||||
@@ -57,7 +59,7 @@ describe('GET /tasks/:id', () => {
|
||||
type: 'habit',
|
||||
});
|
||||
}).then((task) => {
|
||||
return expect(anotherUser.get('/tasks/' + task._id)).to.eventually.be.rejected.and.eql({
|
||||
return expect(anotherUser.get(`/tasks/${task._id}`)).to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('taskNotFound'),
|
||||
|
||||
@@ -47,29 +47,29 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('completes todo when direction is up', () => {
|
||||
return user.post(`/tasks/${todo._id}/score/up`)
|
||||
.then((res) => user.get(`/tasks/${todo._id}`))
|
||||
.then(() => user.get(`/tasks/${todo._id}`))
|
||||
.then((task) => expect(task.completed).to.equal(true));
|
||||
});
|
||||
|
||||
it('moves completed todos out of user.tasksOrder.todos', () => {
|
||||
return user.get('/user')
|
||||
.then(user => {
|
||||
expect(user.tasksOrder.todos.indexOf(todo._id)).to.not.equal(-1);
|
||||
.then(usr => {
|
||||
expect(usr.tasksOrder.todos.indexOf(todo._id)).to.not.equal(-1);
|
||||
}).then(() => user.post(`/tasks/${todo._id}/score/up`))
|
||||
.then(() => user.get(`/tasks/${todo._id}`))
|
||||
.then((updatedTask) => {
|
||||
expect(updatedTask.completed).to.equal(true);
|
||||
return user.get('/user');
|
||||
})
|
||||
.then((user) => {
|
||||
expect(user.tasksOrder.todos.indexOf(todo._id)).to.equal(-1);
|
||||
.then((usr) => {
|
||||
expect(usr.tasksOrder.todos.indexOf(todo._id)).to.equal(-1);
|
||||
});
|
||||
});
|
||||
|
||||
it('moves un-completed todos back into user.tasksOrder.todos', () => {
|
||||
return user.get('/user')
|
||||
.then(user => {
|
||||
expect(user.tasksOrder.todos.indexOf(todo._id)).to.not.equal(-1);
|
||||
.then(usr => {
|
||||
expect(usr.tasksOrder.todos.indexOf(todo._id)).to.not.equal(-1);
|
||||
}).then(() => user.post(`/tasks/${todo._id}/score/up`))
|
||||
.then(() => user.post(`/tasks/${todo._id}/score/down`))
|
||||
.then(() => user.get(`/tasks/${todo._id}`))
|
||||
@@ -77,16 +77,16 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
expect(updatedTask.completed).to.equal(false);
|
||||
return user.get('/user');
|
||||
})
|
||||
.then((user) => {
|
||||
let l = user.tasksOrder.todos.length;
|
||||
expect(user.tasksOrder.todos.indexOf(todo._id)).not.to.equal(-1);
|
||||
expect(user.tasksOrder.todos.indexOf(todo._id)).to.equal(l - 1); // Check that it was pushed at the bottom
|
||||
.then((usr) => {
|
||||
let l = usr.tasksOrder.todos.length;
|
||||
expect(usr.tasksOrder.todos.indexOf(todo._id)).not.to.equal(-1);
|
||||
expect(usr.tasksOrder.todos.indexOf(todo._id)).to.equal(l - 1); // Check that it was pushed at the bottom
|
||||
});
|
||||
});
|
||||
|
||||
it('uncompletes todo when direction is down', () => {
|
||||
return user.post(`/tasks/${todo._id}/score/down`)
|
||||
.then((res) => user.get(`/tasks/${todo._id}`))
|
||||
.then(() => user.get(`/tasks/${todo._id}`))
|
||||
.then((updatedTask) => {
|
||||
expect(updatedTask.completed).to.equal(false);
|
||||
});
|
||||
@@ -98,7 +98,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('increases user\'s mp when direction is up', () => {
|
||||
return user.post(`/tasks/${todo._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.mp).to.be.greaterThan(user.stats.mp);
|
||||
});
|
||||
@@ -106,7 +106,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('decreases user\'s mp when direction is down', () => {
|
||||
return user.post(`/tasks/${todo._id}/score/down`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.mp).to.be.lessThan(user.stats.mp);
|
||||
});
|
||||
@@ -114,7 +114,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('increases user\'s exp when direction is up', () => {
|
||||
return user.post(`/tasks/${todo._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.exp).to.be.greaterThan(user.stats.exp);
|
||||
});
|
||||
@@ -122,7 +122,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('decreases user\'s exp when direction is down', () => {
|
||||
return user.post(`/tasks/${todo._id}/score/down`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.exp).to.be.lessThan(user.stats.exp);
|
||||
});
|
||||
@@ -130,7 +130,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('increases user\'s gold when direction is up', () => {
|
||||
return user.post(`/tasks/${todo._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.gp).to.be.greaterThan(user.stats.gp);
|
||||
});
|
||||
@@ -138,7 +138,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('decreases user\'s gold when direction is down', () => {
|
||||
return user.post(`/tasks/${todo._id}/score/down`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.gp).to.be.lessThan(user.stats.gp);
|
||||
});
|
||||
@@ -159,13 +159,13 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('completes daily when direction is up', () => {
|
||||
return user.post(`/tasks/${daily._id}/score/up`)
|
||||
.then((res) => user.get(`/tasks/${daily._id}`))
|
||||
.then(() => user.get(`/tasks/${daily._id}`))
|
||||
.then((task) => expect(task.completed).to.equal(true));
|
||||
});
|
||||
|
||||
it('uncompletes daily when direction is down', () => {
|
||||
return user.post(`/tasks/${daily._id}/score/down`)
|
||||
.then((res) => user.get(`/tasks/${daily._id}`))
|
||||
.then(() => user.get(`/tasks/${daily._id}`))
|
||||
.then((task) => expect(task.completed).to.equal(false));
|
||||
});
|
||||
|
||||
@@ -175,7 +175,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('increases user\'s mp when direction is up', () => {
|
||||
return user.post(`/tasks/${daily._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.mp).to.be.greaterThan(user.stats.mp);
|
||||
});
|
||||
@@ -183,7 +183,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('decreases user\'s mp when direction is down', () => {
|
||||
return user.post(`/tasks/${daily._id}/score/down`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.mp).to.be.lessThan(user.stats.mp);
|
||||
});
|
||||
@@ -191,7 +191,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('increases user\'s exp when direction is up', () => {
|
||||
return user.post(`/tasks/${daily._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.exp).to.be.greaterThan(user.stats.exp);
|
||||
});
|
||||
@@ -199,7 +199,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('decreases user\'s exp when direction is down', () => {
|
||||
return user.post(`/tasks/${daily._id}/score/down`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.exp).to.be.lessThan(user.stats.exp);
|
||||
});
|
||||
@@ -207,7 +207,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('increases user\'s gold when direction is up', () => {
|
||||
return user.post(`/tasks/${daily._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.gp).to.be.greaterThan(user.stats.gp);
|
||||
});
|
||||
@@ -215,7 +215,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('decreases user\'s gold when direction is down', () => {
|
||||
return user.post(`/tasks/${daily._id}/score/down`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.gp).to.be.lessThan(user.stats.gp);
|
||||
});
|
||||
@@ -223,7 +223,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
});
|
||||
|
||||
context('habits', () => {
|
||||
let habit, minusHabit, plusHabit, neitherHabit;
|
||||
let habit, minusHabit, plusHabit, neitherHabit; // eslint-disable-line no-unused-vars
|
||||
|
||||
beforeEach(() => {
|
||||
return user.post('/tasks', {
|
||||
@@ -262,7 +262,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('increases user\'s mp when direction is up', () => {
|
||||
return user.post(`/tasks/${habit._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.mp).to.be.greaterThan(user.stats.mp);
|
||||
});
|
||||
@@ -270,7 +270,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('decreases user\'s mp when direction is down', () => {
|
||||
return user.post(`/tasks/${habit._id}/score/down`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.mp).to.be.lessThan(user.stats.mp);
|
||||
});
|
||||
@@ -278,7 +278,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('increases user\'s exp when direction is up', () => {
|
||||
return user.post(`/tasks/${habit._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.exp).to.be.greaterThan(user.stats.exp);
|
||||
});
|
||||
@@ -286,7 +286,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('increases user\'s gold when direction is up', () => {
|
||||
return user.post(`/tasks/${habit._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(updatedUser.stats.gp).to.be.greaterThan(user.stats.gp);
|
||||
});
|
||||
@@ -308,7 +308,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('purchases reward', () => {
|
||||
return user.post(`/tasks/${reward._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(user.stats.gp).to.equal(updatedUser.stats.gp + 5);
|
||||
});
|
||||
@@ -316,7 +316,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('does not change user\'s mp', () => {
|
||||
return user.post(`/tasks/${reward._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(user.stats.mp).to.equal(updatedUser.stats.mp);
|
||||
});
|
||||
@@ -324,7 +324,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('does not change user\'s exp', () => {
|
||||
return user.post(`/tasks/${reward._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(user.stats.exp).to.equal(updatedUser.stats.exp);
|
||||
});
|
||||
@@ -332,7 +332,7 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
|
||||
it('does not allow a down direction', () => {
|
||||
return user.post(`/tasks/${reward._id}/score/up`)
|
||||
.then((res) => user.get(`/user`))
|
||||
.then(() => user.get(`/user`))
|
||||
.then((updatedUser) => {
|
||||
expect(user.stats.mp).to.equal(updatedUser.stats.mp);
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {
|
||||
generateUser,
|
||||
translate as t,
|
||||
} from '../../../../helpers/api-integration.helper';
|
||||
import { v4 as generateUUID } from 'uuid';
|
||||
|
||||
@@ -28,7 +27,7 @@ describe('PUT /tasks/:id', () => {
|
||||
it(`ignores setting _id, type, userId, history, createdAt,
|
||||
updatedAt, challenge, completed, streak,
|
||||
dateCompleted fields`, () => {
|
||||
user.put('/tasks/' + task._id, {
|
||||
user.put(`/tasks/${task._id}`, {
|
||||
_id: 123,
|
||||
type: 'daily',
|
||||
userId: 123,
|
||||
@@ -54,7 +53,7 @@ describe('PUT /tasks/:id', () => {
|
||||
});
|
||||
|
||||
it('ignores invalid fields', () => {
|
||||
user.put('/tasks/' + task._id, {
|
||||
user.put(`/tasks/${task._id}`, {
|
||||
notValid: true,
|
||||
}).then((savedTask) => {
|
||||
expect(savedTask.notValid).to.be.a('undefined');
|
||||
@@ -118,12 +117,12 @@ describe('PUT /tasks/:id', () => {
|
||||
checklist: [
|
||||
{text: 123, completed: false},
|
||||
{text: 456, completed: true},
|
||||
]
|
||||
}).then((savedTodo) => {
|
||||
],
|
||||
}).then(() => {
|
||||
return user.put(`/tasks/${todo._id}`, {
|
||||
checklist: [
|
||||
{text: 789, completed: false},
|
||||
]
|
||||
],
|
||||
});
|
||||
}).then((savedTodo2) => {
|
||||
expect(savedTodo2.checklist.length).to.equal(1);
|
||||
@@ -136,9 +135,9 @@ describe('PUT /tasks/:id', () => {
|
||||
let finalUUID = generateUUID();
|
||||
return user.put(`/tasks/${todo._id}`, {
|
||||
tags: [generateUUID(), generateUUID()],
|
||||
}).then((savedTodo) => {
|
||||
}).then(() => {
|
||||
return user.put(`/tasks/${todo._id}`, {
|
||||
tags: [finalUUID]
|
||||
tags: [finalUUID],
|
||||
});
|
||||
}).then((savedTodo2) => {
|
||||
expect(savedTodo2.tags.length).to.equal(1);
|
||||
@@ -161,8 +160,6 @@ describe('PUT /tasks/:id', () => {
|
||||
});
|
||||
|
||||
it('updates a daily', () => {
|
||||
let now = new Date();
|
||||
|
||||
return user.put(`/tasks/${daily._id}`, {
|
||||
text: 'some new text',
|
||||
notes: 'some new notes',
|
||||
@@ -181,12 +178,12 @@ describe('PUT /tasks/:id', () => {
|
||||
checklist: [
|
||||
{text: 123, completed: false},
|
||||
{text: 456, completed: true},
|
||||
]
|
||||
}).then((savedDaily) => {
|
||||
],
|
||||
}).then(() => {
|
||||
return user.put(`/tasks/${daily._id}`, {
|
||||
checklist: [
|
||||
{text: 789, completed: false},
|
||||
]
|
||||
],
|
||||
});
|
||||
}).then((savedDaily2) => {
|
||||
expect(savedDaily2.checklist.length).to.equal(1);
|
||||
@@ -199,9 +196,9 @@ describe('PUT /tasks/:id', () => {
|
||||
let finalUUID = generateUUID();
|
||||
return user.put(`/tasks/${daily._id}`, {
|
||||
tags: [generateUUID(), generateUUID()],
|
||||
}).then((savedDaily) => {
|
||||
}).then(() => {
|
||||
return user.put(`/tasks/${daily._id}`, {
|
||||
tags: [finalUUID]
|
||||
tags: [finalUUID],
|
||||
});
|
||||
}).then((savedDaily2) => {
|
||||
expect(savedDaily2.tags.length).to.equal(1);
|
||||
@@ -212,12 +209,12 @@ describe('PUT /tasks/:id', () => {
|
||||
it('updates repeat, even if frequency is set to daily', () => {
|
||||
return user.put(`/tasks/${daily._id}`, {
|
||||
frequency: 'daily',
|
||||
}).then((savedDaily) => {
|
||||
}).then(() => {
|
||||
return user.put(`/tasks/${daily._id}`, {
|
||||
repeat: {
|
||||
m: false,
|
||||
su: false
|
||||
}
|
||||
su: false,
|
||||
},
|
||||
});
|
||||
}).then((savedDaily2) => {
|
||||
expect(savedDaily2.repeat).to.eql({
|
||||
@@ -235,7 +232,7 @@ describe('PUT /tasks/:id', () => {
|
||||
it('updates everyX, even if frequency is set to weekly', () => {
|
||||
return user.put(`/tasks/${daily._id}`, {
|
||||
frequency: 'weekly',
|
||||
}).then((savedDaily) => {
|
||||
}).then(() => {
|
||||
return user.put(`/tasks/${daily._id}`, {
|
||||
everyX: 5,
|
||||
});
|
||||
|
||||
+5
-7
@@ -46,15 +46,13 @@ describe('DELETE /tasks/:taskId/checklist/:itemId', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('does not work with rewards', () => {
|
||||
let reward;
|
||||
return expect(user.post('/tasks', {
|
||||
it('does not work with rewards', async () => {
|
||||
let reward = await user.post('/tasks', {
|
||||
type: 'reward',
|
||||
text: 'reward with checklist',
|
||||
}).then(createdTask => {
|
||||
reward = createdTask;
|
||||
return user.del(`/tasks/${reward._id}/checklist/${generateUUID()}`);
|
||||
}).then(checklistItem => {})).to.eventually.be.rejected.and.eql({
|
||||
});
|
||||
|
||||
await expect(user.del(`/tasks/${reward._id}/checklist/${generateUUID()}`)).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('checklistOnlyDailyTodo'),
|
||||
|
||||
@@ -66,7 +66,7 @@ describe('POST /tasks/:taskId/checklist/', () => {
|
||||
|
||||
it('fails on task not found', () => {
|
||||
return expect(user.post(`/tasks/${generateUUID()}/checklist`, {
|
||||
text: 'Checklist Item 1'
|
||||
text: 'Checklist Item 1',
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
|
||||
+5
-7
@@ -45,15 +45,13 @@ describe('POST /tasks/:taskId/checklist/:itemId/score', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on rewards', () => {
|
||||
let reward;
|
||||
return expect(user.post('/tasks', {
|
||||
it('fails on rewards', async () => {
|
||||
let reward = await user.post('/tasks', {
|
||||
type: 'reward',
|
||||
text: 'reward with checklist',
|
||||
}).then(createdTask => {
|
||||
reward = createdTask;
|
||||
return user.post(`/tasks/${reward._id}/checklist/${generateUUID()}/score`);
|
||||
}).then(checklistItem => {})).to.eventually.be.rejected.and.eql({
|
||||
});
|
||||
|
||||
await expect(user.post(`/tasks/${reward._id}/checklist/${generateUUID()}/score`)).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('checklistOnlyDailyTodo'),
|
||||
|
||||
+10
-14
@@ -32,30 +32,26 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on habits', () => {
|
||||
let habit;
|
||||
return expect(user.post('/tasks', {
|
||||
it('fails on habits', async () => {
|
||||
let habit = await user.post('/tasks', {
|
||||
type: 'habit',
|
||||
text: 'habit with checklist',
|
||||
}).then(createdTask => {
|
||||
habit = createdTask;
|
||||
return user.put(`/tasks/${habit._id}/checklist/${generateUUID()}`);
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
});
|
||||
|
||||
await expect(user.put(`/tasks/${habit._id}/checklist/${generateUUID()}`)).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('checklistOnlyDailyTodo'),
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on rewards', () => {
|
||||
let reward;
|
||||
return expect(user.post('/tasks', {
|
||||
it('fails on rewards', async () => {
|
||||
let reward = await user.post('/tasks', {
|
||||
type: 'reward',
|
||||
text: 'reward with checklist',
|
||||
}).then(createdTask => {
|
||||
reward = createdTask;
|
||||
return user.put(`/tasks/${reward._id}/checklist/${generateUUID()}`);
|
||||
}).then(checklistItem => {})).to.eventually.be.rejected.and.eql({
|
||||
});
|
||||
|
||||
await expect(user.put(`/tasks/${reward._id}/checklist/${generateUUID()}`)).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('checklistOnlyDailyTodo'),
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('DELETE /tasks/:taskId/tags/:tagId', () => {
|
||||
}).then(createdTag => {
|
||||
tag = createdTag;
|
||||
return user.post(`/tasks/${task._id}/tags/${tag._id}`);
|
||||
}).then(savedTask => {
|
||||
}).then(() => {
|
||||
return user.del(`/tasks/${task._id}/tags/${tag._id}`);
|
||||
}).then(() => user.get(`/tasks/${task._id}`))
|
||||
.then(updatedTask => {
|
||||
@@ -35,8 +35,6 @@ describe('DELETE /tasks/:taskId/tags/:tagId', () => {
|
||||
});
|
||||
|
||||
it('only deletes existing tags', () => {
|
||||
let task;
|
||||
|
||||
return expect(user.post('/tasks', {
|
||||
type: 'habit',
|
||||
text: 'Task with tag',
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('POST /user/auth/local/register', () => {
|
||||
username,
|
||||
email,
|
||||
password,
|
||||
confirmPassword: confirmPassword,
|
||||
confirmPassword,
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
@@ -104,8 +104,8 @@ describe('POST /user/auth/local/register', () => {
|
||||
|
||||
return expect(api.post('/user/auth/local/register', {
|
||||
username,
|
||||
email: email,
|
||||
confirmPassword: confirmPassword,
|
||||
email,
|
||||
confirmPassword,
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
@@ -123,7 +123,7 @@ describe('POST /user/auth/local/register', () => {
|
||||
return generateUser({
|
||||
'auth.local.username': username,
|
||||
'auth.local.lowerCaseUsername': username,
|
||||
'auth.local.email': email
|
||||
'auth.local.email': email,
|
||||
});
|
||||
});
|
||||
|
||||
@@ -133,9 +133,9 @@ describe('POST /user/auth/local/register', () => {
|
||||
let password = 'password';
|
||||
|
||||
return expect(api.post('/user/auth/local/register', {
|
||||
username: username,
|
||||
email: uniqueEmail,
|
||||
password: password,
|
||||
username,
|
||||
email: uniqueEmail,
|
||||
password,
|
||||
confirmPassword: password,
|
||||
})).to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
@@ -181,7 +181,7 @@ describe('POST /user/auth/local/register', () => {
|
||||
}).then((user) => {
|
||||
expect(user.flags.tour).to.not.be.empty;
|
||||
|
||||
each(user.flags.tour, (value, attribute) => {
|
||||
each(user.flags.tour, (value) => {
|
||||
expect(value).to.eql(-2);
|
||||
});
|
||||
});
|
||||
@@ -232,7 +232,7 @@ describe('POST /user/auth/local/register', () => {
|
||||
}).then((user) => {
|
||||
expect(user.flags.tour).to.not.be.empty;
|
||||
|
||||
each(user.flags.tutorial.common, (value, attribute) => {
|
||||
each(user.flags.tutorial.common, (value) => {
|
||||
expect(value).to.eql(true);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user