-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Chai Things, updated tests, updated get user challenges, and ad…
…ded get user challenges tests
- Loading branch information
1 parent
6716d1f
commit e81a371
Showing
5 changed files
with
79 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
test/api/v3/integration/challenges/GET-challenges_user.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { | ||
generateUser, | ||
generateChallenge, | ||
createAndPopulateGroup, | ||
} from '../../../../helpers/api-v3-integration.helper'; | ||
|
||
describe('GET challenges/user', () => { | ||
let user, member, nonMember, challenge, challenge2; | ||
|
||
before(async () => { | ||
let { group, groupLeader, members } = await createAndPopulateGroup({ | ||
groupDetails: { | ||
name: 'TestGuild', | ||
type: 'guild', | ||
privacy: 'public', | ||
}, | ||
members: 1, | ||
}); | ||
|
||
user = groupLeader; | ||
|
||
member = members[0]; | ||
nonMember = await generateUser(); | ||
|
||
challenge = await generateChallenge(user, group); | ||
challenge2 = await generateChallenge(user, group); | ||
}); | ||
|
||
it('should return challenges user has joined', async () => { | ||
await nonMember.post(`/challenges/${challenge._id}/join`); | ||
|
||
let challenges = await nonMember.get(`/challenges/user`); | ||
|
||
challenges.should.contain.a.item.with.property('_id', challenge._id); | ||
}); | ||
|
||
it('should return challenges user has created', async () => { | ||
let challenges = await user.get(`/challenges/user`); | ||
|
||
challenges.should.contain.a.item.with.property('_id', challenge._id); | ||
challenges.should.contain.a.item.with.property('_id', challenge2._id); | ||
}); | ||
|
||
it('should return challenges in user\'s group', async () => { | ||
let challenges = await member.get(`/challenges/user`); | ||
|
||
challenges.should.contain.a.item.with.property('_id', challenge._id); | ||
challenges.should.contain.a.item.with.property('_id', challenge2._id); | ||
}); | ||
|
||
it('should not return challenges user doesn\'t have access to', async () => { | ||
let { group, groupLeader } = await createAndPopulateGroup({ | ||
groupDetails: { | ||
name: 'TestPrivateGuild', | ||
type: 'guild', | ||
privacy: 'private', | ||
}, | ||
}); | ||
|
||
let privateChallenge = await generateChallenge(groupLeader, group); | ||
|
||
let challenges = await nonMember.get(`/challenges/user`); | ||
|
||
challenges.should.not.contain.a.item.with.property('_id', privateChallenge._id); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters