v3: misc fixes

This commit is contained in:
Matteo Pagliazzi
2016-05-12 18:06:26 +02:00
parent c9b7aa8342
commit 93336f3894
20 changed files with 74 additions and 33 deletions
@@ -43,9 +43,10 @@ describe('GET /challenges/:challengeId', () => {
expect(chal.leader).to.eql({
_id: groupLeader._id,
id: groupLeader._id,
profile: {name: groupLeader.profile.name},
});
expect(chal.group).to.eql(_.pick(group, ['_id', 'name', 'type', 'privacy']));
expect(chal.group).to.eql(_.pick(group, ['_id', 'id', 'name', 'type', 'privacy']));
});
});
@@ -87,9 +88,10 @@ describe('GET /challenges/:challengeId', () => {
expect(chal.leader).to.eql({
_id: groupLeader._id,
id: groupLeader._id,
profile: {name: groupLeader.profile.name},
});
expect(chal.group).to.eql(_.pick(group, ['_id', 'name', 'type', 'privacy']));
expect(chal.group).to.eql(_.pick(group, ['_id', 'id', 'name', 'type', 'privacy']));
});
});
@@ -131,9 +133,10 @@ describe('GET /challenges/:challengeId', () => {
expect(chal.leader).to.eql({
_id: groupLeader._id,
id: groupLeader.id,
profile: {name: groupLeader.profile.name},
});
expect(chal.group).to.eql(_.pick(group, ['_id', 'name', 'type', 'privacy']));
expect(chal.group).to.eql(_.pick(group, ['_id', 'id', 'name', 'type', 'privacy']));
});
});
});
@@ -48,9 +48,10 @@ describe('GET /challenges/:challengeId/members', () => {
let res = await user.get(`/challenges/${challenge._id}/members`);
expect(res[0]).to.eql({
_id: leader._id,
id: leader._id,
profile: {name: leader.profile.name},
});
expect(res[0]).to.have.all.keys(['_id', 'profile']);
expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']);
expect(res[0].profile).to.have.all.keys(['name']);
});
@@ -61,9 +62,10 @@ describe('GET /challenges/:challengeId/members', () => {
let res = await user.get(`/challenges/${challenge._id}/members`);
expect(res[0]).to.eql({
_id: anotherUser._id,
id: anotherUser._id,
profile: {name: anotherUser.profile.name},
});
expect(res[0]).to.have.all.keys(['_id', 'profile']);
expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']);
expect(res[0].profile).to.have.all.keys(['name']);
});
@@ -80,7 +82,7 @@ describe('GET /challenges/:challengeId/members', () => {
let res = await user.get(`/challenges/${challenge._id}/members`);
expect(res.length).to.equal(30);
res.forEach(member => {
expect(member).to.have.all.keys(['_id', 'profile']);
expect(member).to.have.all.keys(['_id', 'id', 'profile']);
expect(member.profile).to.have.all.keys(['name']);
});
});
@@ -78,7 +78,7 @@ describe('GET /challenges/:challengeId/members/:memberId', () => {
await groupLeader.post(`/tasks/challenge/${challenge._id}`, [{type: 'habit', text: taskText}]);
let memberProgress = await user.get(`/challenges/${challenge._id}/members/${groupLeader._id}`);
expect(memberProgress).to.have.all.keys(['_id', 'profile', 'tasks']);
expect(memberProgress).to.have.all.keys(['_id', 'id', 'profile', 'tasks']);
expect(memberProgress.profile).to.have.all.keys(['name']);
expect(memberProgress.tasks.length).to.equal(1);
});
@@ -34,12 +34,14 @@ describe('GET challenges/group/:groupId', () => {
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
});
});
@@ -51,12 +53,14 @@ describe('GET challenges/group/:groupId', () => {
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
});
});
@@ -99,12 +103,14 @@ describe('GET challenges/group/:groupId', () => {
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: privateGuild.leader._id,
id: privateGuild.leader._id,
profile: {name: user.profile.name},
});
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: privateGuild.leader._id,
id: privateGuild.leader._id,
profile: {name: user.profile.name},
});
});
@@ -35,6 +35,7 @@ describe('GET challenges/user', () => {
expect(foundChallenge).to.exist;
expect(foundChallenge.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
});
expect(foundChallenge.group).to.eql({
@@ -52,6 +53,7 @@ describe('GET challenges/user', () => {
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
});
expect(foundChallenge1.group).to.eql({
@@ -64,6 +66,7 @@ describe('GET challenges/user', () => {
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
});
expect(foundChallenge2.group).to.eql({
@@ -81,6 +84,7 @@ describe('GET challenges/user', () => {
expect(foundChallenge1).to.exist;
expect(foundChallenge1.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
});
expect(foundChallenge1.group).to.eql({
@@ -93,6 +97,7 @@ describe('GET challenges/user', () => {
expect(foundChallenge2).to.exist;
expect(foundChallenge2.leader).to.eql({
_id: publicGuild.leader._id,
id: publicGuild.leader._id,
profile: {name: user.profile.name},
});
expect(foundChallenge2.group).to.eql({
@@ -66,6 +66,7 @@ describe('POST /challenges/:challengeId/join', () => {
});
expect(res.leader).to.eql({
_id: groupLeader._id,
id: groupLeader._id,
profile: {name: groupLeader.profile.name},
});
expect(res.name).to.equal(challenge.name);
@@ -76,6 +76,7 @@ describe('PUT /challenges/:challengeId', () => {
expect(res.leader).to.eql({
_id: member._id,
id: member._id,
profile: {name: member.profile.name},
});
expect(res.name).to.equal('New Challenge Name');
@@ -48,6 +48,7 @@ describe('GET /groups/:groupId/invites', () => {
expect(res.length).to.equal(1);
expect(res[0]).to.eql({
_id: invited._id,
id: invited._id,
profile: {name: invited.profile.name},
});
});
@@ -57,7 +58,7 @@ describe('GET /groups/:groupId/invites', () => {
let invited = await generateUser();
await user.post(`/groups/${group._id}/invite`, {uuids: [invited._id]});
let res = await user.get('/groups/party/invites');
expect(res[0]).to.have.all.keys(['_id', 'profile']);
expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']);
expect(res[0].profile).to.have.all.keys(['name']);
});
@@ -73,7 +74,7 @@ describe('GET /groups/:groupId/invites', () => {
let res = await user.get('/groups/party/invites');
expect(res.length).to.equal(30);
res.forEach(member => {
expect(member).to.have.all.keys(['_id', 'profile']);
expect(member).to.have.all.keys(['_id', 'id', 'profile']);
expect(member.profile).to.have.all.keys(['name']);
});
});
@@ -45,6 +45,7 @@ describe('GET /groups/:groupId/members', () => {
expect(res.length).to.equal(1);
expect(res[0]).to.eql({
_id: user._id,
id: user._id,
profile: {name: user.profile.name},
});
});
@@ -52,7 +53,7 @@ describe('GET /groups/:groupId/members', () => {
it('populates only some fields', async () => {
await generateGroup(user, {type: 'party', name: generateUUID()});
let res = await user.get('/groups/party/members');
expect(res[0]).to.have.all.keys(['_id', 'profile']);
expect(res[0]).to.have.all.keys(['_id', 'id', 'profile']);
expect(res[0].profile).to.have.all.keys(['name']);
});
@@ -68,7 +69,7 @@ describe('GET /groups/:groupId/members', () => {
let res = await user.get('/groups/party/members');
expect(res.length).to.equal(30);
res.forEach(member => {
expect(member).to.have.all.keys(['_id', 'profile']);
expect(member).to.have.all.keys(['_id', 'id', 'profile']);
expect(member.profile).to.have.all.keys(['name']);
});
});
@@ -47,7 +47,7 @@ describe('GET /heroes/:heroId', () => {
let heroRes = await user.get(`/hall/heroes/${hero._id}`);
expect(heroRes).to.have.all.keys([ // works as: object has all and only these keys
'_id', 'balance', 'profile', 'purchased',
'_id', 'id', 'balance', 'profile', 'purchased',
'contributor', 'auth', 'items',
]);
expect(heroRes.auth.local).not.to.have.keys(['salt', 'hashed_password']);
@@ -30,7 +30,7 @@ describe('GET /members/:memberId', () => {
});
let memberRes = await user.get(`/members/${member._id}`);
expect(memberRes).to.have.all.keys([ // works as: object has all and only these keys
'_id', 'preferences', 'profile', 'stats', 'achievements', 'party',
'_id', 'id', 'preferences', 'profile', 'stats', 'achievements', 'party',
'backer', 'contributor', 'auth', 'items',
]);
expect(Object.keys(memberRes.auth)).to.eql(['timestamps']);