api v3 adapt v2: correctly import dependencies, port create, get, list groups

This commit is contained in:
Matteo Pagliazzi
2016-04-04 23:18:49 +02:00
parent f6fc50f6c2
commit 0a40c56973
17 changed files with 258 additions and 123 deletions
+5 -5
View File
@@ -4,11 +4,11 @@ import {
resetHabiticaDB,
} from '../../../helpers/api-integration/v2';
xdescribe('GET /groups', () => {
describe('GET /groups', () => {
const NUMBER_OF_PUBLIC_GUILDS = 3;
const NUMBER_OF_USERS_GUILDS = 2;
let user;
let leader;
before(async () => {
// Set up a world with a mixture of public and private guilds
@@ -16,7 +16,7 @@ xdescribe('GET /groups', () => {
await resetHabiticaDB();
user = await generateUser();
let leader = await generateUser({ balance: 10 });
leader = await generateUser({ balance: 10 });
await generateGroup(leader, {
name: 'public guild - is member',
@@ -90,8 +90,8 @@ xdescribe('GET /groups', () => {
context('guilds passed in as query', () => {
it('returns all guilds user is a part of ', async () => {
await expect(user.get('/groups', null, {type: 'guilds'}))
.to.eventually.have.a.lengthOf(NUMBER_OF_USERS_GUILDS);
await expect(leader.get('/groups', null, {type: 'guilds'}))
.to.eventually.have.a.lengthOf(4);
});
});
});
+1 -1
View File
@@ -8,7 +8,7 @@ import {
each,
} from 'lodash';
xdescribe('GET /groups/:id', () => {
describe('GET /groups/:id', () => {
let typesOfGroups = {};
typesOfGroups['public guild'] = { type: 'guild', privacy: 'public' };
typesOfGroups['private guild'] = { type: 'guild', privacy: 'private' };
+1 -1
View File
@@ -4,7 +4,7 @@ import {
translate as t,
} from '../../../helpers/api-integration/v2';
xdescribe('POST /groups', () => {
describe('POST /groups', () => {
context('All groups', () => {
let leader;
+17 -1
View File
@@ -4,7 +4,11 @@ import {
generateGroup,
generateUser,
} from '../../../helpers/api-integration/v2';
import { find } from 'lodash';
import {
find,
map,
} from 'lodash';
import Q from 'q';
xdescribe('DELETE /user', () => {
let user;
@@ -19,6 +23,18 @@ xdescribe('DELETE /user', () => {
})).to.eventually.eql(false);
});
it('deletes the user\'s tasks', async () => {
// gets the user's todos ids
let ids = user.todos.map(todo => todo._id);
expect(ids.length).to.be.above(0); // make sure the user has some task to delete
await user.del('/user');
await Q.all(map(ids, id => {
return expect(checkExistence('tasks', id)).to.eventually.eql(false);
}));
});
context('user has active subscription', () => {
it('does not delete account');
});
@@ -42,7 +42,7 @@ describe('DELETE /user', () => {
});
});
it('deletes the user', async () => {
it('deletes the user\'s tasks', async () => {
// gets the user's tasks ids
let ids = [];
each(user.tasksOrder, (idsForOrder) => {
@@ -60,7 +60,7 @@ describe('DELETE /user', () => {
}));
});
it('delete the user\'s tasks', async () => {
it('deletes the user', async () => {
await user.del('/user', {
password,
});