Updated test syntax and added get user challenges tests

This commit is contained in:
Keith Holliday
2016-02-02 10:29:55 -06:00
parent 461eb96d45
commit 754befc580
3 changed files with 90 additions and 11 deletions

View File

@@ -30,15 +30,19 @@ describe('GET challenges/group/:groupId', () => {
it('should return group challenges for non member', async () => {
let challenges = await nonMember.get(`/challenges/groups/${publicGuild._id}`);
expect(_.findIndex(challenges, {_id: challenge._id})).to.be.above(-1);
expect(_.findIndex(challenges, {_id: challenge2._id})).to.be.above(-1);
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
});
it('should return group challenges for member', async () => {
let challenges = await user.get(`/challenges/groups/${publicGuild._id}`);
expect(_.findIndex(challenges, {_id: challenge._id})).to.be.above(-1);
expect(_.findIndex(challenges, {_id: challenge2._id})).to.be.above(-1);
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
});
});
@@ -75,8 +79,10 @@ describe('GET challenges/group/:groupId', () => {
it('should return group challenges for member', async () => {
let challenges = await user.get(`/challenges/groups/${privateGuild._id}`);
expect(_.findIndex(challenges, {_id: challenge._id})).to.be.above(-1);
expect(_.findIndex(challenges, {_id: challenge2._id})).to.be.above(-1);
let foundChallenge1 = _.find(challenges, { _id: challenge._id });
expect(foundChallenge1).to.exist;
let foundChallenge2 = _.find(challenges, { _id: challenge2._id });
expect(foundChallenge2).to.exist;
});
});
});