change tasks routes to /tasks/(user|challenge)

This commit is contained in:
Matteo Pagliazzi
2016-01-06 18:40:11 +01:00
parent 2b2dcfe7ce
commit 8ba486ec12
13 changed files with 248 additions and 158 deletions

View File

@@ -2,7 +2,7 @@ import {
generateUser,
} from '../../../../helpers/api-integration.helper';
describe('GET /tasks', () => {
describe('GET /tasks/user', () => {
let user;
beforeEach(async () => {
@@ -16,14 +16,14 @@ describe('GET /tasks', () => {
});
it('returns all user\'s tasks', async () => {
let createdTasks = await user.post('/tasks?tasksOwner=user', [{text: 'test habit', type: 'habit'}, {text: 'test todo', type: 'todo'}]);
let tasks = await user.get('/tasks?tasksOwner=user');
let createdTasks = await user.post('/tasks/user', [{text: 'test habit', type: 'habit'}, {text: 'test todo', type: 'todo'}]);
let tasks = await user.get('/tasks/user');
expect(tasks.length).to.equal(createdTasks.length + 1); // + 1 because 1 is a default task
});
it('returns only a type of user\'s tasks if req.query.type is specified', async () => {
let createdTasks = await user.post('/tasks?tasksOwner=user', [{text: 'test habit', type: 'habit'}, {text: 'test todo', type: 'todo'}]);
let tasks = await user.get('/tasks?tasksOwner=user&type=habit');
let createdTasks = await user.post('/tasks/user', [{text: 'test habit', type: 'habit'}, {text: 'test todo', type: 'todo'}]);
let tasks = await user.get('/tasks/user?type=habit');
expect(tasks.length).to.equal(1);
expect(tasks[0]._id).to.equal(createdTasks[0]._id);
});