add population to join and update routes of challenges and groups, remove chat flags info everywhere

This commit is contained in:
Matteo Pagliazzi
2016-02-03 11:29:19 +01:00
parent a8dc529449
commit 1daf87531a
9 changed files with 114 additions and 39 deletions
@@ -55,6 +55,22 @@ describe('POST /challenges/:challengeId/join', () => {
});
});
it('returns challenge data', async () => {
let res = await authorizedUser.post(`/challenges/${challenge._id}/join`);
expect(res.group).to.eql({
_id: group._id,
privacy: group.privacy,
name: group.name,
type: group.type,
});
expect(res.leader).to.eql({
_id: groupLeader._id,
profile: {name: groupLeader.profile.name},
});
expect(res.name).to.equal(challenge.name);
});
it('adds challenge to user challenges', async () => {
await authorizedUser.post(`/challenges/${challenge._id}/join`);
@@ -63,13 +63,21 @@ describe('PUT /challenges/:challengeId', () => {
});
expect(res.prize).to.equal(0);
expect(res.group).to.equal(privateGuild._id);
expect(res.group).to.eql({
_id: privateGuild._id,
privacy: privateGuild.privacy,
name: privateGuild.name,
type: privateGuild.type,
});
expect(res.memberCount).to.equal(2);
expect(res.tasksOrder).not.to.equal('new order');
expect(res.official).to.equal(false);
expect(res.shortName).not.to.equal('new short name');
expect(res.leader).to.equal(member._id);
expect(res.leader).to.eql({
_id: member._id,
profile: {name: member.profile.name},
});
expect(res.name).to.equal('New Challenge Name');
expect(res.description).to.equal('New challenge description.');
});
@@ -23,8 +23,8 @@ describe('GET /groups/:groupId/chat', () => {
privacy: 'public',
}, {
chat: [
'Hello',
'Welcome to the Guild',
{text: 'Hello', flags: {}},
{text: 'Welcome to the Guild', flags: {}},
],
});
});
@@ -35,9 +35,11 @@ describe('POST /group/:groupId/join', () => {
});
it('allows non-invited users to join public guilds', async () => {
await joiningUser.post(`/groups/${publicGuild._id}/join`);
let res = await joiningUser.post(`/groups/${publicGuild._id}/join`);
await expect(joiningUser.get('/user')).to.eventually.have.property('guilds').to.include(publicGuild._id);
expect(res.leader._id).to.eql(user._id);
expect(res.leader.profile.name).to.eql(user.profile.name);
});
it('promotes joining member in a public empty guild to leader', async () => {
@@ -39,6 +39,8 @@ describe('PUT /group', () => {
name: groupUpdatedName,
});
expect(updatedGroup.leader._id).to.eql(leader._id);
expect(updatedGroup.leader.profile.name).to.eql(leader.profile.name);
expect(updatedGroup.name).to.equal(groupUpdatedName);
});
});