Ensured group tasks are removed from places that challegnes tasks are (#8359)

* Ensured group tasks are removed from places that challegnes tasks are

* Added tests for user reset and class cast
This commit is contained in:
Keith Holliday
2017-01-07 05:01:12 -06:00
committed by Matteo Pagliazzi
parent 28e8ec2d2c
commit 857aa5827b
7 changed files with 72 additions and 9 deletions

View File

@@ -5,7 +5,7 @@ import {
} from '../../../../helpers/api-integration/v3';
describe('POST /tasks/clearCompletedTodos', () => {
it('deletes all completed todos except the ones from a challenge', async () => {
it('deletes all completed todos except the ones from a challenge and group', async () => {
let user = await generateUser({balance: 1});
let guild = await generateGroup(user);
let challenge = await generateChallenge(user, guild);
@@ -24,8 +24,14 @@ describe('POST /tasks/clearCompletedTodos', () => {
type: 'todo',
});
let groupTask = await user.post(`/tasks/group/${guild._id}`, {
text: 'todo 7',
type: 'todo',
});
await user.post(`/tasks/${groupTask._id}/assign/${user._id}`);
let tasks = await user.get('/tasks/user?type=todos');
expect(tasks.length).to.equal(initialTodoCount + 6);
expect(tasks.length).to.equal(initialTodoCount + 7);
for (let task of tasks) {
if (['todo 2', 'todo 3', 'todo 6'].indexOf(task.text) !== -1) {
@@ -38,6 +44,6 @@ describe('POST /tasks/clearCompletedTodos', () => {
let todos = await user.get('/tasks/user?type=todos');
let allTodos = todos.concat(completedTodos);
expect(allTodos.length).to.equal(initialTodoCount + 4); // + 6 - 3 completed (but one is from challenge)
expect(allTodos[allTodos.length - 1].text).to.equal('todo 6');
expect(allTodos[allTodos.length - 1].text).to.equal('todo 7');
});
});