mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Upgrade tests tools and lint migrations and scripts (part 2) (#9998)
* upgrade gulp-babel * upgrade babel-eslint * upgrade eslint-friendly-formatter * start upgrading chai * start to upgrade eslint * restore skipped tests * start to upgrqde monk * fix linting and remove unused file * fix mocha notifications, and common tests * fix unit tests * start to fix initrgration tests * more integration tests fixes * upgrade monk to latest version * lint /scripts * migrations: start moving to /archive unused migrations and run eslint with --fix * lint migrations * fix more integration tests * fix test
This commit is contained in:
@@ -99,7 +99,7 @@ describe('POST /challenges/:challengeId/winner/:winnerId', () => {
|
||||
|
||||
await sleep(0.5);
|
||||
|
||||
await expect(winningUser.sync()).to.eventually.have.deep.property('achievements.challenges').to.include(challenge.name);
|
||||
await expect(winningUser.sync()).to.eventually.have.nested.property('achievements.challenges').to.include(challenge.name);
|
||||
expect(winningUser.notifications.length).to.equal(2); // 2 because winningUser just joined the challenge, which now awards an achievement
|
||||
expect(winningUser.notifications[1].type).to.equal('WON_CHALLENGE');
|
||||
});
|
||||
|
||||
@@ -119,21 +119,21 @@ describe('POST /chat', () => {
|
||||
it('errors when word is part of a phrase', async () => {
|
||||
let wordInPhrase = `phrase ${testBannedWordMessage} end`;
|
||||
await expect(user.post('/groups/habitrpg/chat', { message: wordInPhrase}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: bannedWordErrorMessage,
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: bannedWordErrorMessage,
|
||||
});
|
||||
});
|
||||
|
||||
it('errors when word is surrounded by non alphabet characters', async () => {
|
||||
let wordInPhrase = `_!${testBannedWordMessage}@_`;
|
||||
await expect(user.post('/groups/habitrpg/chat', { message: wordInPhrase}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: bannedWordErrorMessage,
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: bannedWordErrorMessage,
|
||||
});
|
||||
});
|
||||
|
||||
it('checks error message has the banned words used', async () => {
|
||||
|
||||
@@ -7,19 +7,19 @@ import i18n from '../../../../../website/common/script/i18n';
|
||||
describe('GET /content', () => {
|
||||
it('returns content (and does not require authentication)', async () => {
|
||||
let res = await requester().get('/content');
|
||||
expect(res).to.have.deep.property('backgrounds.backgrounds062014.beach');
|
||||
expect(res).to.have.nested.property('backgrounds.backgrounds062014.beach');
|
||||
expect(res.backgrounds.backgrounds062014.beach.text).to.equal(t('backgroundBeachText'));
|
||||
});
|
||||
|
||||
it('returns content not in English', async () => {
|
||||
let res = await requester().get('/content?language=de');
|
||||
expect(res).to.have.deep.property('backgrounds.backgrounds062014.beach');
|
||||
expect(res).to.have.nested.property('backgrounds.backgrounds062014.beach');
|
||||
expect(res.backgrounds.backgrounds062014.beach.text).to.equal(i18n.t('backgroundBeachText', 'de'));
|
||||
});
|
||||
|
||||
it('falls back to English if the desired language is not found', async () => {
|
||||
let res = await requester().get('/content?language=wrong');
|
||||
expect(res).to.have.deep.property('backgrounds.backgrounds062014.beach');
|
||||
expect(res).to.have.nested.property('backgrounds.backgrounds062014.beach');
|
||||
expect(res.backgrounds.backgrounds062014.beach.text).to.equal(t('backgroundBeachText'));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,10 +26,10 @@ describe('POST /debug/add-ten-gems', () => {
|
||||
nconf.set('IS_PROD', true);
|
||||
|
||||
await expect(userToGainTenGems.post('/debug/add-ten-gems'))
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -26,10 +26,10 @@ describe('POST /debug/make-admin (pended for v3 prod testing)', () => {
|
||||
nconf.set('IS_PROD', true);
|
||||
|
||||
await expect(user.post('/debug/make-admin'))
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -151,10 +151,10 @@ describe('POST /debug/modify-inventory', () => {
|
||||
nconf.set('IS_PROD', true);
|
||||
|
||||
await expect(user.post('/debug/modify-inventory'))
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,11 +16,11 @@ describe('POST /debug/quest-progress', () => {
|
||||
|
||||
it('errors if user is not on a quest', async () => {
|
||||
await expect(user.post('/debug/quest-progress'))
|
||||
.to.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: 'User is not on a valid quest.',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: 'User is not on a valid quest.',
|
||||
});
|
||||
});
|
||||
|
||||
it('increases boss quest progress by 1000', async () => {
|
||||
@@ -51,10 +51,10 @@ describe('POST /debug/quest-progress', () => {
|
||||
nconf.set('IS_PROD', true);
|
||||
|
||||
await expect(user.post('/debug/quest-progress'))
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -30,10 +30,10 @@ describe('POST /debug/set-cron', () => {
|
||||
nconf.set('IS_PROD', true);
|
||||
|
||||
await expect(user.post('/debug/set-cron'))
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
.eventually.be.rejected.and.to.deep.equal({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: 'Not found.',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -93,14 +93,14 @@ describe('GET /groups', () => {
|
||||
it('returns only the tavern when tavern passed in as query', async () => {
|
||||
await expect(user.get('/groups?type=tavern'))
|
||||
.to.eventually.have.a.lengthOf(1)
|
||||
.and.to.have.deep.property('[0]')
|
||||
.and.to.have.nested.property('[0]')
|
||||
.and.to.have.property('_id', TAVERN_ID);
|
||||
});
|
||||
|
||||
it('returns only the user\'s party when party passed in as query', async () => {
|
||||
await expect(user.get('/groups?type=party'))
|
||||
.to.eventually.have.a.lengthOf(1)
|
||||
.and.to.have.deep.property('[0]');
|
||||
.and.to.have.nested.property('[0]');
|
||||
});
|
||||
|
||||
it('returns all public guilds when publicGuilds passed in as query', async () => {
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
|
||||
await joiningUser.post(`/groups/${publicGuild._id}/join`);
|
||||
|
||||
await expect(joiningUser.get(`/groups/${publicGuild._id}`)).to.eventually.have.deep.property('leader._id', joiningUser._id);
|
||||
await expect(joiningUser.get(`/groups/${publicGuild._id}`)).to.eventually.have.nested.property('leader._id', joiningUser._id);
|
||||
});
|
||||
|
||||
it('increments memberCount when joining guilds', async () => {
|
||||
@@ -72,7 +72,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
it('awards Joined Guild achievement', async () => {
|
||||
await joiningUser.post(`/groups/${publicGuild._id}/join`);
|
||||
|
||||
await expect(joiningUser.get('/user')).to.eventually.have.deep.property('achievements.joinedGuild', true);
|
||||
await expect(joiningUser.get('/user')).to.eventually.have.nested.property('achievements.joinedGuild', true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -115,7 +115,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
await invitedUser.post(`/groups/${guild._id}/join`);
|
||||
|
||||
await expect(invitedUser.get('/user'))
|
||||
.to.eventually.have.deep.property('invitations.guilds')
|
||||
.to.eventually.have.nested.property('invitations.guilds')
|
||||
.to.not.include({id: guild._id});
|
||||
});
|
||||
|
||||
@@ -130,7 +130,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
it('does not give basilist quest to inviter when joining a guild', async () => {
|
||||
await invitedUser.post(`/groups/${guild._id}/join`);
|
||||
|
||||
await expect(user.get('/user')).to.eventually.not.have.deep.property('items.quests.basilist');
|
||||
await expect(user.get('/user')).to.eventually.not.have.nested.property('items.quests.basilist');
|
||||
});
|
||||
|
||||
it('does not increment basilist quest count to inviter with basilist when joining a guild', async () => {
|
||||
@@ -138,7 +138,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
|
||||
await invitedUser.post(`/groups/${guild._id}/join`);
|
||||
|
||||
await expect(user.get('/user')).to.eventually.have.deep.property('items.quests.basilist', 1);
|
||||
await expect(user.get('/user')).to.eventually.have.nested.property('items.quests.basilist', 1);
|
||||
});
|
||||
|
||||
it('notifies inviting user that their invitation was accepted', async () => {
|
||||
@@ -160,7 +160,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
it('awards Joined Guild achievement', async () => {
|
||||
await invitedUser.post(`/groups/${guild._id}/join`);
|
||||
|
||||
await expect(invitedUser.get('/user')).to.eventually.have.deep.property('achievements.joinedGuild', true);
|
||||
await expect(invitedUser.get('/user')).to.eventually.have.nested.property('achievements.joinedGuild', true);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -197,7 +197,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
it('allows invited user to join party', async () => {
|
||||
await invitedUser.post(`/groups/${party._id}/join`);
|
||||
|
||||
await expect(invitedUser.get('/user')).to.eventually.have.deep.property('party._id', party._id);
|
||||
await expect(invitedUser.get('/user')).to.eventually.have.nested.property('party._id', party._id);
|
||||
});
|
||||
|
||||
it('notifies inviting user that their invitation was accepted', async () => {
|
||||
@@ -220,7 +220,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
it('clears invitation from user when joining party', async () => {
|
||||
await invitedUser.post(`/groups/${party._id}/join`);
|
||||
|
||||
await expect(invitedUser.get('/user')).to.eventually.not.have.deep.property('invitations.parties[0].id');
|
||||
await expect(invitedUser.get('/user')).to.eventually.not.have.nested.property('invitations.parties[0].id');
|
||||
});
|
||||
|
||||
it('increments memberCount when joining party', async () => {
|
||||
@@ -234,7 +234,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
it('gives basilist quest item to the inviter when joining a party', async () => {
|
||||
await invitedUser.post(`/groups/${party._id}/join`);
|
||||
|
||||
await expect(user.get('/user')).to.eventually.have.deep.property('items.quests.basilist', 1);
|
||||
await expect(user.get('/user')).to.eventually.have.nested.property('items.quests.basilist', 1);
|
||||
});
|
||||
|
||||
it('increments basilist quest item count to inviter when joining a party', async () => {
|
||||
@@ -242,7 +242,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
|
||||
await invitedUser.post(`/groups/${party._id}/join`);
|
||||
|
||||
await expect(user.get('/user')).to.eventually.have.deep.property('items.quests.basilist', 2);
|
||||
await expect(user.get('/user')).to.eventually.have.nested.property('items.quests.basilist', 2);
|
||||
});
|
||||
|
||||
it('deletes previous party where the user was the only member', async () => {
|
||||
@@ -258,7 +258,7 @@ describe('POST /group/:groupId/join', () => {
|
||||
});
|
||||
await userToInvite.post(`/groups/${party._id}/join`);
|
||||
|
||||
await expect(user.get('/user')).to.eventually.have.deep.property('party._id', party._id);
|
||||
await expect(user.get('/user')).to.eventually.have.nested.property('party._id', party._id);
|
||||
await expect(checkExistence('groups', oldParty._id)).to.eventually.equal(false);
|
||||
});
|
||||
|
||||
@@ -273,8 +273,8 @@ describe('POST /group/:groupId/join', () => {
|
||||
await invitedUser.sync();
|
||||
await party.sync();
|
||||
|
||||
expect(invitedUser).to.have.deep.property('party.quest.RSVPNeeded', true);
|
||||
expect(invitedUser).to.have.deep.property('party.quest.key', party.quest.key);
|
||||
expect(invitedUser).to.have.nested.property('party.quest.RSVPNeeded', true);
|
||||
expect(invitedUser).to.have.nested.property('party.quest.key', party.quest.key);
|
||||
expect(party.quest.members[invitedUser._id]).to.be.null;
|
||||
});
|
||||
});
|
||||
@@ -300,16 +300,16 @@ describe('POST /group/:groupId/join', () => {
|
||||
await member.sync();
|
||||
await leader.sync();
|
||||
|
||||
expect(member).to.have.deep.property('achievements.partyUp', true);
|
||||
expect(leader).to.have.deep.property('achievements.partyUp', true);
|
||||
expect(member).to.have.nested.property('achievements.partyUp', true);
|
||||
expect(leader).to.have.nested.property('achievements.partyUp', true);
|
||||
});
|
||||
|
||||
it('does not award Party On achievement to party of size 2', async () => {
|
||||
await member.sync();
|
||||
await leader.sync();
|
||||
|
||||
expect(member).to.not.have.deep.property('achievements.partyOn');
|
||||
expect(leader).to.not.have.deep.property('achievements.partyOn');
|
||||
expect(member).to.not.have.nested.property('achievements.partyOn');
|
||||
expect(leader).to.not.have.nested.property('achievements.partyOn');
|
||||
});
|
||||
|
||||
it('awards Party On achievement to party of size 4', async () => {
|
||||
@@ -324,8 +324,8 @@ describe('POST /group/:groupId/join', () => {
|
||||
await member.sync();
|
||||
await leader.sync();
|
||||
|
||||
expect(member).to.have.deep.property('achievements.partyOn', true);
|
||||
expect(leader).to.have.deep.property('achievements.partyOn', true);
|
||||
expect(member).to.have.nested.property('achievements.partyOn', true);
|
||||
expect(leader).to.have.nested.property('achievements.partyOn', true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -85,7 +85,7 @@ describe('POST /groups/:groupId/leave', () => {
|
||||
expect(leader.notifications.find(n => {
|
||||
return n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === groupToLeave._id;
|
||||
})).to.not.exist;
|
||||
expect(leader.newMessages[groupToLeave._id]).to.be.empty;
|
||||
expect(leader.newMessages[groupToLeave._id]).to.be.undefined;
|
||||
});
|
||||
|
||||
context('with challenges', () => {
|
||||
@@ -257,7 +257,7 @@ describe('POST /groups/:groupId/leave', () => {
|
||||
|
||||
let userWithoutInvitation = await invitedUser.get('/user');
|
||||
|
||||
expect(userWithoutInvitation.invitations.parties[0]).to.be.empty;
|
||||
expect(userWithoutInvitation.invitations.parties[0]).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ describe('POST /group/:groupId/reject-invite', () => {
|
||||
await invitedUser.post(`/groups/${publicGuild._id}/reject-invite`);
|
||||
|
||||
await expect(invitedUser.get('/user'))
|
||||
.to.eventually.have.deep.property('invitations.guilds')
|
||||
.to.eventually.have.nested.property('invitations.guilds')
|
||||
.to.not.include({id: publicGuild._id});
|
||||
});
|
||||
});
|
||||
@@ -72,7 +72,7 @@ describe('POST /group/:groupId/reject-invite', () => {
|
||||
await invitedUser.post(`/groups/${guild._id}/reject-invite`);
|
||||
|
||||
await expect(invitedUser.get('/user'))
|
||||
.to.eventually.have.deep.property('invitations.guilds')
|
||||
.to.eventually.have.nested.property('invitations.guilds')
|
||||
.to.not.include({id: guild._id});
|
||||
});
|
||||
});
|
||||
@@ -107,7 +107,7 @@ describe('POST /group/:groupId/reject-invite', () => {
|
||||
it('clears invitation from user', async () => {
|
||||
await invitedUser.post(`/groups/${party._id}/reject-invite`);
|
||||
|
||||
await expect(invitedUser.get('/user')).to.eventually.not.have.deep.property('invitations.parties[0].id');
|
||||
await expect(invitedUser.get('/user')).to.eventually.not.have.nested.property('invitations.parties[0].id');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -184,7 +184,7 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
|
||||
|
||||
let invitedUserWithoutInvite = await partyInvitedUser.get('/user');
|
||||
|
||||
expect(invitedUserWithoutInvite.invitations.parties[0]).to.be.empty;
|
||||
expect(invitedUserWithoutInvite.invitations.parties[0]).to.be.undefined;
|
||||
});
|
||||
|
||||
it('removes new messages from a member who is removed', async () => {
|
||||
@@ -203,7 +203,7 @@ describe('POST /groups/:groupId/removeMember/:memberId', () => {
|
||||
expect(removedMember.notifications.find(n => {
|
||||
return n.type === 'NEW_CHAT_MESSAGE' && n.data.group.id === party._id;
|
||||
})).to.not.exist;
|
||||
expect(removedMember.newMessages[party._id]).to.be.empty;
|
||||
expect(removedMember.newMessages[party._id]).to.be.undefined;
|
||||
});
|
||||
|
||||
it('removes user from quest when removing user from party after quest starts', async () => {
|
||||
|
||||
@@ -30,22 +30,22 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
uuids: [fakeID],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('userWithIDNotFound', {userId: fakeID}),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('userWithIDNotFound', {userId: fakeID}),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when inviting yourself to a group', async () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
uuids: [inviter._id],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('cannotInviteSelfToGroup'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('cannotInviteSelfToGroup'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when uuids is not an array', async () => {
|
||||
@@ -54,11 +54,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
uuids: {fakeID},
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('uuidsMustBeAnArray'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('uuidsMustBeAnArray'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when uuids and emails are empty', async () => {
|
||||
@@ -66,22 +66,22 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
emails: [],
|
||||
uuids: [],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('inviteMustNotBeEmpty'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('inviteMustNotBeEmpty'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when uuids is empty and emails is not passed', async () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
uuids: [],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('inviteMissingUuid'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('inviteMissingUuid'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when there are more than INVITES_LIMIT uuids', async () => {
|
||||
@@ -94,11 +94,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
uuids,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('canOnlyInviteMaxInvites', {maxInvites: INVITES_LIMIT}),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('canOnlyInviteMaxInvites', {maxInvites: INVITES_LIMIT}),
|
||||
});
|
||||
});
|
||||
|
||||
it('invites a user to a group by uuid', async () => {
|
||||
@@ -114,7 +114,7 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
}]);
|
||||
|
||||
await expect(userToInvite.get('/user'))
|
||||
.to.eventually.have.deep.property('invitations.guilds[0].id', group._id);
|
||||
.to.eventually.have.nested.property('invitations.guilds[0].id', group._id);
|
||||
});
|
||||
|
||||
it('invites multiple users to a group by uuid', async () => {
|
||||
@@ -138,8 +138,8 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
},
|
||||
]);
|
||||
|
||||
await expect(userToInvite.get('/user')).to.eventually.have.deep.property('invitations.guilds[0].id', group._id);
|
||||
await expect(userToInvite2.get('/user')).to.eventually.have.deep.property('invitations.guilds[0].id', group._id);
|
||||
await expect(userToInvite.get('/user')).to.eventually.have.nested.property('invitations.guilds[0].id', group._id);
|
||||
await expect(userToInvite2.get('/user')).to.eventually.have.nested.property('invitations.guilds[0].id', group._id);
|
||||
});
|
||||
|
||||
it('returns an error when inviting multiple users and a user is not found', async () => {
|
||||
@@ -149,11 +149,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
uuids: [userToInvite._id, fakeID],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('userWithIDNotFound', {userId: fakeID}),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('userWithIDNotFound', {userId: fakeID}),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -164,33 +164,33 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
emails: [{name: 'test'}],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('inviteMissingEmail'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('inviteMissingEmail'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when emails is not an array', async () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
emails: {testInvite},
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('emailsMustBeAnArray'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('emailsMustBeAnArray'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when emails is empty and uuids is not passed', async () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
emails: [],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('inviteMissingEmail'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('inviteMissingEmail'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when there are more than INVITES_LIMIT emails', async () => {
|
||||
@@ -203,11 +203,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
emails,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('canOnlyInviteMaxInvites', {maxInvites: INVITES_LIMIT}),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('canOnlyInviteMaxInvites', {maxInvites: INVITES_LIMIT}),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when a user has sent the max number of email invites', async () => {
|
||||
@@ -224,11 +224,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
emails: [testInvite],
|
||||
inviter: 'inviter name',
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('inviteLimitReached', {techAssistanceEmail: nconf.get('EMAILS:TECH_ASSISTANCE_EMAIL')}),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('inviteLimitReached', {techAssistanceEmail: nconf.get('EMAILS:TECH_ASSISTANCE_EMAIL')}),
|
||||
});
|
||||
});
|
||||
|
||||
it('invites a user to a group by email', async () => {
|
||||
@@ -258,11 +258,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
describe('user and email invites', () => {
|
||||
it('returns an error when emails and uuids are not provided', async () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('canOnlyInviteEmailUuid'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('canOnlyInviteEmailUuid'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when there are more than INVITES_LIMIT uuids and emails', async () => {
|
||||
@@ -281,11 +281,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
emails,
|
||||
uuids,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('canOnlyInviteMaxInvites', {maxInvites: INVITES_LIMIT}),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('canOnlyInviteMaxInvites', {maxInvites: INVITES_LIMIT}),
|
||||
});
|
||||
});
|
||||
|
||||
it('invites users to a group by uuid and email', async () => {
|
||||
@@ -330,11 +330,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
uuids: [userToInivite._id],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('userAlreadyInvitedToGroup'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('userAlreadyInvitedToGroup'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when invited user is already in the group', async () => {
|
||||
@@ -347,11 +347,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${group._id}/invite`, {
|
||||
uuids: [userToInvite._id],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('userAlreadyInGroup'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('userAlreadyInGroup'),
|
||||
});
|
||||
});
|
||||
|
||||
it('allows 30+ members in a guild', async () => {
|
||||
@@ -380,11 +380,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(nonGroupLeader.post(`/groups/${group._id}/invite`, {
|
||||
uuids: [userToInvite._id],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('onlyGroupLeaderCanInviteToGroupPlan'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('onlyGroupLeaderCanInviteToGroupPlan'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -407,11 +407,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${party._id}/invite`, {
|
||||
uuids: [userToInvite._id],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('userAlreadyPendingInvitation'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('userAlreadyPendingInvitation'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when invited user is already in a party of more than 1 member', async () => {
|
||||
@@ -426,11 +426,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${party._id}/invite`, {
|
||||
uuids: [userToInvite._id],
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('userAlreadyInAParty'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('userAlreadyInAParty'),
|
||||
});
|
||||
});
|
||||
|
||||
it('allow inviting a user to a party if they are partying solo', async () => {
|
||||
@@ -512,11 +512,11 @@ describe('Post /groups/:groupId/invite', () => {
|
||||
await expect(inviter.post(`/groups/${party._id}/invite`, {
|
||||
uuids: generatedInvites.map(invite => invite._id),
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('partyExceedsMembersLimit', {maxMembersParty: PARTY_LIMIT_MEMBERS}),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('partyExceedsMembersLimit', {maxMembersParty: PARTY_LIMIT_MEMBERS}),
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,7 +24,7 @@ describe('POST /news/tell-me-later', () => {
|
||||
const notification = user.notifications[user.notifications.length - 1];
|
||||
|
||||
expect(notification.type).to.equal('NEW_STUFF');
|
||||
// should be marked as seen by default so it's not counted in the number of notifications
|
||||
// should be marked as seen by default so it's not counted in the number of notifications
|
||||
expect(notification.seen).to.equal(true);
|
||||
expect(notification.data.title).to.be.a.string;
|
||||
});
|
||||
|
||||
@@ -26,9 +26,9 @@ describe('payments : apple #verify', () => {
|
||||
});
|
||||
|
||||
await user.post(endpoint, {
|
||||
transaction: {
|
||||
receipt: 'receipt',
|
||||
}});
|
||||
transaction: {
|
||||
receipt: 'receipt',
|
||||
}});
|
||||
|
||||
expect(verifyStub).to.be.calledOnce;
|
||||
expect(verifyStub.args[0][0]._id).to.eql(user._id);
|
||||
|
||||
@@ -33,20 +33,20 @@ describe('POST /groups/:groupId/quests/accept', () => {
|
||||
context('failure conditions', () => {
|
||||
it('does not accept quest without an invite', async () => {
|
||||
await expect(leader.post(`/groups/${questingGroup._id}/quests/accept`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('questInviteNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('questInviteNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('does not accept quest for a group in which user is not a member', async () => {
|
||||
await expect(user.post(`/groups/${questingGroup._id}/quests/accept`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('does not accept quest for a guild', async () => {
|
||||
@@ -55,11 +55,11 @@ describe('POST /groups/:groupId/quests/accept', () => {
|
||||
});
|
||||
|
||||
await expect(guildLeader.post(`/groups/${guild._id}/quests/accept`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
});
|
||||
|
||||
it('does not accept invite twice', async () => {
|
||||
@@ -67,11 +67,11 @@ describe('POST /groups/:groupId/quests/accept', () => {
|
||||
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
|
||||
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyAccepted'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyAccepted'),
|
||||
});
|
||||
});
|
||||
|
||||
it('clears the invalid invite from the user when the request fails', async () => {
|
||||
@@ -79,11 +79,11 @@ describe('POST /groups/:groupId/quests/accept', () => {
|
||||
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
|
||||
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyAccepted'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyAccepted'),
|
||||
});
|
||||
|
||||
await partyMembers[0].sync();
|
||||
expect(partyMembers[0].party.quest.RSVPNeeded).to.be.false;
|
||||
@@ -96,11 +96,11 @@ describe('POST /groups/:groupId/quests/accept', () => {
|
||||
await partyMembers[1].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
|
||||
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('questAlreadyUnderway'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('questAlreadyUnderway'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -32,11 +32,11 @@ describe('POST /groups/:groupId/quests/force-start', () => {
|
||||
let nonMember = await generateUser();
|
||||
|
||||
await expect(nonMember.post(`/groups/${questingGroup._id}/quests/force-start`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('does not force start quest for a guild', async () => {
|
||||
@@ -45,20 +45,20 @@ describe('POST /groups/:groupId/quests/force-start', () => {
|
||||
});
|
||||
|
||||
await expect(guildLeader.post(`/groups/${guild._id}/quests/force-start`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
});
|
||||
|
||||
it('does not force start for a party without a pending quest', async () => {
|
||||
await expect(leader.post(`/groups/${questingGroup._id}/quests/force-start`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('questNotPending'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('questNotPending'),
|
||||
});
|
||||
});
|
||||
|
||||
it('does not force start for a quest already underway', async () => {
|
||||
@@ -69,22 +69,22 @@ describe('POST /groups/:groupId/quests/force-start', () => {
|
||||
await partyMembers[2].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
|
||||
await expect(leader.post(`/groups/${questingGroup._id}/quests/force-start`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('questAlreadyUnderway'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('questAlreadyUnderway'),
|
||||
});
|
||||
});
|
||||
|
||||
it('does not allow non-quest leader or non-group leader to force start a quest', async () => {
|
||||
await leader.post(`/groups/${questingGroup._id}/quests/invite/${PET_QUEST}`);
|
||||
|
||||
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/force-start`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('questOrGroupLeaderOnlyStartQuest'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('questOrGroupLeaderOnlyStartQuest'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ describe('POST /groups/:groupId/quests/abort', () => {
|
||||
|
||||
it('returns an error for a group in which user is not a member', async () => {
|
||||
await expect(user.post(`/groups/${questingGroup._id}/quests/abort`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when group is a guild', async () => {
|
||||
@@ -55,11 +55,11 @@ describe('POST /groups/:groupId/quests/abort', () => {
|
||||
});
|
||||
|
||||
await expect(guildLeader.post(`/groups/${guild._id}/quests/abort`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when quest is not active', async () => {
|
||||
|
||||
@@ -41,11 +41,11 @@ describe('POST /groups/:groupId/quests/cancel', () => {
|
||||
|
||||
it('does not reject quest for a group in which user is not a member', async () => {
|
||||
await expect(user.post(`/groups/${questingGroup._id}/quests/cancel`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when group is a guild', async () => {
|
||||
@@ -54,11 +54,11 @@ describe('POST /groups/:groupId/quests/cancel', () => {
|
||||
});
|
||||
|
||||
await expect(guildLeader.post(`/groups/${guild._id}/quests/cancel`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when group is not on a quest', async () => {
|
||||
@@ -74,11 +74,11 @@ describe('POST /groups/:groupId/quests/cancel', () => {
|
||||
await leader.post(`/groups/${questingGroup._id}/quests/invite/${PET_QUEST}`);
|
||||
|
||||
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/cancel`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('onlyLeaderCancelQuest'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('onlyLeaderCancelQuest'),
|
||||
});
|
||||
});
|
||||
|
||||
it('does not cancel a quest already underway', async () => {
|
||||
@@ -88,11 +88,11 @@ describe('POST /groups/:groupId/quests/cancel', () => {
|
||||
await partyMembers[1].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
|
||||
await expect(leader.post(`/groups/${questingGroup._id}/quests/cancel`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('cantCancelActiveQuest'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('cantCancelActiveQuest'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -41,11 +41,11 @@ describe('POST /groups/:groupId/quests/leave', () => {
|
||||
|
||||
it('returns an error for a group in which user is not a member', async () => {
|
||||
await expect(user.post(`/groups/${questingGroup._id}/quests/leave`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when group is a guild', async () => {
|
||||
@@ -54,11 +54,11 @@ describe('POST /groups/:groupId/quests/leave', () => {
|
||||
});
|
||||
|
||||
await expect(guildLeader.post(`/groups/${guild._id}/quests/leave`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when quest is not active', async () => {
|
||||
@@ -89,11 +89,11 @@ describe('POST /groups/:groupId/quests/leave', () => {
|
||||
await partyMembers[1].post(`/groups/${questingGroup._id}/quests/reject`);
|
||||
|
||||
await expect(partyMembers[1].post(`/groups/${questingGroup._id}/quests/leave`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('notPartOfQuest'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('notPartOfQuest'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -42,11 +42,11 @@ describe('POST /groups/:groupId/quests/reject', () => {
|
||||
|
||||
it('does not accept quest for a group in which user is not a member', async () => {
|
||||
await expect(user.post(`/groups/${questingGroup._id}/quests/accept`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when group is a guild', async () => {
|
||||
@@ -55,11 +55,11 @@ describe('POST /groups/:groupId/quests/reject', () => {
|
||||
});
|
||||
|
||||
await expect(guildLeader.post(`/groups/${guild._id}/quests/reject`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('guildQuestsNotSupported'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns an error when group is not on a quest', async () => {
|
||||
@@ -76,11 +76,11 @@ describe('POST /groups/:groupId/quests/reject', () => {
|
||||
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/reject`);
|
||||
|
||||
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/reject`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyRejected'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyRejected'),
|
||||
});
|
||||
});
|
||||
|
||||
it('clears the user rsvp needed if the request fails because the request is invalid', async () => {
|
||||
@@ -88,11 +88,11 @@ describe('POST /groups/:groupId/quests/reject', () => {
|
||||
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/reject`);
|
||||
|
||||
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/reject`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyRejected'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyRejected'),
|
||||
});
|
||||
|
||||
await partyMembers[0].sync();
|
||||
expect(partyMembers[0].party.quest.RSVPNeeded).to.be.false;
|
||||
@@ -103,11 +103,11 @@ describe('POST /groups/:groupId/quests/reject', () => {
|
||||
await partyMembers[0].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
|
||||
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/reject`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyAccepted'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('questAlreadyAccepted'),
|
||||
});
|
||||
});
|
||||
|
||||
it('does not reject invite for a quest already underway', async () => {
|
||||
@@ -117,11 +117,11 @@ describe('POST /groups/:groupId/quests/reject', () => {
|
||||
await partyMembers[1].post(`/groups/${questingGroup._id}/quests/accept`);
|
||||
|
||||
await expect(partyMembers[0].post(`/groups/${questingGroup._id}/quests/reject`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('questAlreadyUnderway'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('questAlreadyUnderway'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -141,11 +141,11 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
it('doesn\'t let a todo be completed twice', async () => {
|
||||
await user.post(`/tasks/${todo._id}/score/up`);
|
||||
await expect(user.post(`/tasks/${todo._id}/score/up`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('sessionOutdated'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('sessionOutdated'),
|
||||
});
|
||||
});
|
||||
|
||||
it('doesn\'t let a todo be uncompleted twice', async () => {
|
||||
@@ -380,11 +380,11 @@ describe('POST /tasks/:id/score/:direction', () => {
|
||||
await expect(user.post(`/tasks/${habit._id}/score/up`, {
|
||||
scoreNotes: scoreNotesString,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('taskScoreNotesTooLong'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('taskScoreNotesTooLong'),
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -41,30 +41,30 @@ describe('POST /tasks/unlink-all/:challengeId', () => {
|
||||
|
||||
it('fails if no keep query', async () => {
|
||||
await expect(user.post(`/tasks/unlink-all/${challenge._id}`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('invalidReqParams'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('invalidReqParams'),
|
||||
});
|
||||
});
|
||||
|
||||
it('fails if invalid challenge id', async () => {
|
||||
await expect(user.post('/tasks/unlink-all/123?keep=remove-all'))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('invalidReqParams'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('invalidReqParams'),
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on an unbroken challenge', async () => {
|
||||
await user.post(`/tasks/challenge/${challenge._id}`, tasksToTest.daily);
|
||||
await expect(user.post(`/tasks/unlink-all/${challenge._id}?keep=remove-all`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('cantOnlyUnlinkChalTask'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('cantOnlyUnlinkChalTask'),
|
||||
});
|
||||
});
|
||||
|
||||
it('unlinks all tasks from a challenge and deletes them on keep=remove-all', async () => {
|
||||
@@ -87,7 +87,7 @@ describe('POST /tasks/unlink-all/:challengeId', () => {
|
||||
const daily = await user.post(`/tasks/challenge/${challenge._id}`, tasksToTest.daily);
|
||||
const anotherUser = await generateUser();
|
||||
await user.post(`/groups/${guild._id}/invite`, {
|
||||
uuids: [anotherUser._id],
|
||||
uuids: [anotherUser._id],
|
||||
});
|
||||
// Have the second user join the group and challenge
|
||||
await anotherUser.post(`/groups/${guild._id}/join`);
|
||||
|
||||
@@ -43,50 +43,50 @@ describe('POST /tasks/unlink-one/:taskId', () => {
|
||||
it('fails if no keep query', async () => {
|
||||
const daily = await user.post(`/tasks/challenge/${challenge._id}`, tasksToTest.daily);
|
||||
await expect(user.post(`/tasks/unlink-one/${daily._id}`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('invalidReqParams'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('invalidReqParams'),
|
||||
});
|
||||
});
|
||||
|
||||
it('fails if invalid task id', async () => {
|
||||
await expect(user.post('/tasks/unlink-one/123?keep=remove'))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('invalidReqParams'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('invalidReqParams'),
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on task not found', async () => {
|
||||
await expect(user.post(`/tasks/unlink-one/${generateUUID()}?keep=keep`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('taskNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('taskNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on task unlinked to challenge', async () => {
|
||||
let daily = await user.post('/tasks/user', tasksToTest.daily);
|
||||
await expect(user.post(`/tasks/unlink-one/${daily._id}?keep=keep`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('cantOnlyUnlinkChalTask'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('cantOnlyUnlinkChalTask'),
|
||||
});
|
||||
});
|
||||
|
||||
it('fails on unbroken challenge', async () => {
|
||||
await user.post(`/tasks/challenge/${challenge._id}`, tasksToTest.daily);
|
||||
let [daily] = await user.get('/tasks/user');
|
||||
await expect(user.post(`/tasks/unlink-one/${daily._id}?keep=keep`))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('cantOnlyUnlinkChalTask'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 400,
|
||||
error: 'BadRequest',
|
||||
message: t('cantOnlyUnlinkChalTask'),
|
||||
});
|
||||
});
|
||||
|
||||
it('unlinks a task from a challenge and saves it on keep=keep', async () => {
|
||||
|
||||
@@ -46,7 +46,7 @@ describe('PUT /tasks/:id', () => {
|
||||
expect(savedTask.userId).to.equal(task.userId);
|
||||
expect(savedTask.history).to.eql(task.history);
|
||||
expect(savedTask.createdAt).to.equal(task.createdAt);
|
||||
expect(savedTask.updatedAt).to.be.greaterThan(task.updatedAt);
|
||||
expect(new Date(savedTask.updatedAt)).to.be.greaterThan(new Date(task.updatedAt));
|
||||
expect(savedTask.challenge).to.eql(task.challenge);
|
||||
expect(savedTask.completed).to.eql(task.completed);
|
||||
expect(savedTask.streak).to.equal(savedTask.streak); // it's an habit, dailies can change it
|
||||
@@ -54,7 +54,7 @@ describe('PUT /tasks/:id', () => {
|
||||
});
|
||||
|
||||
it('ignores invalid fields', async () => {
|
||||
let savedTask = await user.put(`/tasks/${task._id}`, {
|
||||
let savedTask = await user.put(`/tasks/${task._id}`, {
|
||||
notValid: true,
|
||||
});
|
||||
|
||||
@@ -133,7 +133,7 @@ describe('PUT /tasks/:id', () => {
|
||||
expect(savedChallengeUserTask.text).to.equal(challengeUserTask.text);
|
||||
expect(savedChallengeUserTask.history).to.eql(challengeUserTask.history);
|
||||
expect(savedChallengeUserTask.createdAt).to.equal(challengeUserTask.createdAt);
|
||||
expect(savedChallengeUserTask.updatedAt).to.be.greaterThan(challengeUserTask.updatedAt);
|
||||
expect(new Date(savedChallengeUserTask.updatedAt)).to.be.greaterThan(new Date(challengeUserTask.updatedAt));
|
||||
expect(savedChallengeUserTask.challenge).to.eql(challengeUserTask.challenge);
|
||||
expect(savedChallengeUserTask.completed).to.equal(challengeUserTask.completed);
|
||||
expect(savedChallengeUserTask.dateCompleted).to.equal(challengeUserTask.dateCompleted);
|
||||
|
||||
@@ -40,11 +40,11 @@ describe('POST /tasks/:taskId/checklist/', () => {
|
||||
ignored: false,
|
||||
_id: 123,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('onlyChalLeaderEditTasks'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('onlyChalLeaderEditTasks'),
|
||||
});
|
||||
});
|
||||
|
||||
it('adds a checklist item to a daily', async () => {
|
||||
|
||||
@@ -98,7 +98,7 @@ describe('PUT /tasks/:id', () => {
|
||||
expect(savedTask.userId).to.equal(task.userId);
|
||||
expect(savedTask.history).to.eql(task.history);
|
||||
expect(savedTask.createdAt).to.equal(task.createdAt);
|
||||
expect(savedTask.updatedAt).to.be.greaterThan(task.updatedAt);
|
||||
expect(new Date(savedTask.updatedAt)).to.be.greaterThan(new Date(task.updatedAt));
|
||||
expect(savedTask.challenge._id).to.equal(task.challenge._id);
|
||||
expect(savedTask.completed).to.equal(task.completed);
|
||||
expect(savedTask.streak).to.equal(task.streak);
|
||||
|
||||
@@ -28,11 +28,11 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
|
||||
completed: true,
|
||||
_id: 123, // ignored
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('checklistItemNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 404,
|
||||
error: 'NotFound',
|
||||
message: t('checklistItemNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('returns error when user is not a member of the challenge', async () => {
|
||||
@@ -53,11 +53,11 @@ describe('PUT /tasks/:taskId/checklist/:itemId', () => {
|
||||
completed: true,
|
||||
_id: 123, // ignored
|
||||
}))
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('onlyChalLeaderEditTasks'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.eql({
|
||||
code: 401,
|
||||
error: 'NotAuthorized',
|
||||
message: t('onlyChalLeaderEditTasks'),
|
||||
});
|
||||
});
|
||||
|
||||
it('updates a checklist item on dailies', async () => {
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
translate as t,
|
||||
} from '../../../../../../helpers/api-integration/v3';
|
||||
import { v4 as generateUUID } from 'uuid';
|
||||
|
||||
// Currently we do not support adding tags to group original tasks, but if we do in the future, these tests will check
|
||||
xdescribe('POST group /tasks/:taskId/tags/:tagId', () => {
|
||||
let user, guild, task;
|
||||
|
||||
@@ -54,9 +54,9 @@ describe('POST /user/release-both', () => {
|
||||
|
||||
expect(response.message).to.equal(t('mountsAndPetsReleased'));
|
||||
expect(user.balance).to.equal(0);
|
||||
expect(user.items.currentMount).to.be.empty;
|
||||
expect(user.items.currentPet).to.be.empty;
|
||||
expect(user.items.pets[animal]).to.be.empty;
|
||||
expect(user.items.currentMount).to.equal('');
|
||||
expect(user.items.currentPet).to.equal('');
|
||||
expect(user.items.pets[animal]).to.equal(0);
|
||||
expect(user.items.mounts[animal]).to.equal(null);
|
||||
expect(user.achievements.beastMasterCount).to.equal(1);
|
||||
expect(user.achievements.mountMasterCount).to.equal(1);
|
||||
|
||||
@@ -41,7 +41,7 @@ describe('DELETE social registration', () => {
|
||||
let response = await user.del('/user/auth/social/facebook');
|
||||
expect(response).to.eql({});
|
||||
await user.sync();
|
||||
expect(user.auth.facebook).to.be.empty;
|
||||
expect(user.auth.facebook).to.be.undefined;
|
||||
});
|
||||
|
||||
it('succeeds if user has a google registration', async () => {
|
||||
@@ -54,7 +54,7 @@ describe('DELETE social registration', () => {
|
||||
let response = await user.del('/user/auth/social/facebook');
|
||||
expect(response).to.eql({});
|
||||
await user.sync();
|
||||
expect(user.auth.facebook).to.be.empty;
|
||||
expect(user.auth.facebook).to.be.undefined;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -79,7 +79,7 @@ describe('DELETE social registration', () => {
|
||||
let response = await user.del('/user/auth/social/google');
|
||||
expect(response).to.eql({});
|
||||
await user.sync();
|
||||
expect(user.auth.google).to.be.empty;
|
||||
expect(user.auth.google).to.be.undefined;
|
||||
});
|
||||
|
||||
it('succeeds if user has a facebook registration', async () => {
|
||||
@@ -92,7 +92,7 @@ describe('DELETE social registration', () => {
|
||||
let response = await user.del('/user/auth/social/google');
|
||||
expect(response).to.eql({});
|
||||
await user.sync();
|
||||
expect(user.auth.google).to.be.empty;
|
||||
expect(user.auth.goodl).to.be.undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -579,7 +579,7 @@ describe('POST /user/auth/local/register', () => {
|
||||
|
||||
it('adds a user to a guild on an invite of type other than party', async () => {
|
||||
let { group, groupLeader } = await createAndPopulateGroup({
|
||||
groupDetails: { type: 'guild', privacy: 'private' },
|
||||
groupDetails: { type: 'guild', privacy: 'private' },
|
||||
});
|
||||
|
||||
let invite = encrypt(JSON.stringify({
|
||||
|
||||
@@ -19,7 +19,7 @@ describe('GET /world-state', () => {
|
||||
await updateDocument('groups', {_id: TAVERN_ID}, {quest: {active: true, key: 'dysheartener', progress: {hp: 50000, rage: 9999}}});
|
||||
|
||||
const res = await requester().get('/world-state');
|
||||
expect(res).to.have.deep.property('worldBoss');
|
||||
expect(res).to.have.nested.property('worldBoss');
|
||||
|
||||
expect(res.worldBoss).to.eql({
|
||||
active: true,
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('API Messages', () => {
|
||||
let vars = {a: 1};
|
||||
sandbox.stub(_, 'clone').returns({});
|
||||
apiMessages('guildsOnlyPaginate', vars);
|
||||
expect(_.clone).to.have.been.called.once;
|
||||
expect(_.clone).to.have.been.calledOnce;
|
||||
expect(_.clone).to.have.been.calledWith(vars);
|
||||
});
|
||||
|
||||
@@ -23,9 +23,9 @@ describe('API Messages', () => {
|
||||
let stub = sinon.stub().returns('string');
|
||||
sandbox.stub(_, 'template').returns(stub);
|
||||
apiMessages('guildsOnlyPaginate', vars);
|
||||
expect(_.template).to.have.been.called.once;
|
||||
expect(_.template).to.have.been.calledOnce;
|
||||
expect(_.template).to.have.been.calledWith(message);
|
||||
expect(stub).to.have.been.called.once;
|
||||
expect(stub).to.have.been.calledOnce;
|
||||
expect(stub).to.have.been.calledWith(vars);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import mongoose from 'mongoose';
|
||||
import {
|
||||
removeFromArray,
|
||||
removeFromArray,
|
||||
} from '../../../../../website/server/libs/collectionManipulators';
|
||||
|
||||
describe('Collection Manipulators', () => {
|
||||
|
||||
@@ -181,9 +181,9 @@ describe('cron', () => {
|
||||
cron({user, tasksByType, daysMissed, analytics});
|
||||
|
||||
expect(user.purchased.plan.customerId).to.not.exist;
|
||||
expect(user.purchased.plan.consecutive.gemCapExtra).to.be.empty;
|
||||
expect(user.purchased.plan.consecutive.count).to.be.empty;
|
||||
expect(user.purchased.plan.consecutive.offset).to.be.empty;
|
||||
expect(user.purchased.plan.consecutive.gemCapExtra).to.equal(0);
|
||||
expect(user.purchased.plan.consecutive.count).to.equal(0);
|
||||
expect(user.purchased.plan.consecutive.offset).to.equal(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1027,7 +1027,7 @@ describe('cron', () => {
|
||||
cron({user, tasksByType, daysMissed, analytics});
|
||||
expect(user.party.quest.progress.up).to.equal(0);
|
||||
expect(user.party.quest.progress.down).to.equal(0);
|
||||
expect(user.party.quest.progress.collectedItems).to.be.empty;
|
||||
expect(user.party.quest.progress.collectedItems).to.equal(0);
|
||||
});
|
||||
|
||||
it('applies the user progress', () => {
|
||||
|
||||
@@ -132,11 +132,11 @@ describe('Amazon Payments - Checkout', () => {
|
||||
};
|
||||
|
||||
await expect(amzLib.checkout({gift, user, orderReferenceId, headers}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
});
|
||||
|
||||
it('should error if user cannot get gems gems', async () => {
|
||||
|
||||
@@ -123,11 +123,11 @@ describe('Amazon Payments - Subscribe', () => {
|
||||
groupId,
|
||||
headers,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('missingSubscriptionCode'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('missingSubscriptionCode'),
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error if we are missing a billingAgreementId', async () => {
|
||||
@@ -138,11 +138,11 @@ describe('Amazon Payments - Subscribe', () => {
|
||||
groupId,
|
||||
headers,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.billingAgreementId',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.billingAgreementId',
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error when coupon code is missing', async () => {
|
||||
@@ -156,11 +156,11 @@ describe('Amazon Payments - Subscribe', () => {
|
||||
groupId,
|
||||
headers,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('couponCodeRequired'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('couponCodeRequired'),
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error when coupon code is invalid', async () => {
|
||||
@@ -182,11 +182,11 @@ describe('Amazon Payments - Subscribe', () => {
|
||||
groupId,
|
||||
headers,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('invalidCoupon'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('invalidCoupon'),
|
||||
});
|
||||
cc.validate.restore();
|
||||
});
|
||||
|
||||
|
||||
@@ -305,7 +305,7 @@ describe('Purchasing a group plan for group', () => {
|
||||
|
||||
await api.createSubscription(data);
|
||||
|
||||
expect(sender.sendTxn).to.be.calledFourTimes;
|
||||
expect(sender.sendTxn).to.have.callCount(4);
|
||||
expect(sender.sendTxn.args[0][0]._id).to.equal(TECH_ASSISTANCE_EMAIL);
|
||||
expect(sender.sendTxn.args[0][1]).to.equal('admin-user-subscription-details');
|
||||
expect(sender.sendTxn.args[1][0]._id).to.equal(recipient._id);
|
||||
@@ -338,7 +338,7 @@ describe('Purchasing a group plan for group', () => {
|
||||
|
||||
await api.createSubscription(data);
|
||||
|
||||
expect(sender.sendTxn).to.be.calledFourTimes;
|
||||
expect(sender.sendTxn).to.have.callCount(4);
|
||||
expect(sender.sendTxn.args[0][0]._id).to.equal(TECH_ASSISTANCE_EMAIL);
|
||||
expect(sender.sendTxn.args[0][1]).to.equal('admin-user-subscription-details');
|
||||
expect(sender.sendTxn.args[1][0]._id).to.equal(recipient._id);
|
||||
|
||||
@@ -71,11 +71,11 @@ describe('checkout', () => {
|
||||
};
|
||||
|
||||
await expect(paypalPayments.checkout({gift}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
});
|
||||
|
||||
it('should error if the user cannot get gems', async () => {
|
||||
|
||||
@@ -42,11 +42,11 @@ describe('cancel subscription', () => {
|
||||
user,
|
||||
groupId: undefined,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('missingSubscription'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('missingSubscription'),
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if the group is not found', async () => {
|
||||
@@ -54,11 +54,11 @@ describe('cancel subscription', () => {
|
||||
user,
|
||||
groupId: 'fake-group',
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 404,
|
||||
name: 'NotFound',
|
||||
message: i18n.t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 404,
|
||||
name: 'NotFound',
|
||||
message: i18n.t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if user is not the group leader', async () => {
|
||||
@@ -70,11 +70,11 @@ describe('cancel subscription', () => {
|
||||
user: nonLeader,
|
||||
groupId,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('onlyGroupLeaderCanManageSubscription'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('onlyGroupLeaderCanManageSubscription'),
|
||||
});
|
||||
});
|
||||
|
||||
describe('success', () => {
|
||||
|
||||
@@ -88,11 +88,11 @@ describe('checkout with subscription', () => {
|
||||
headers,
|
||||
coupon,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.id',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.id',
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error when coupon code is missing', async () => {
|
||||
@@ -108,11 +108,11 @@ describe('checkout with subscription', () => {
|
||||
headers,
|
||||
coupon,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('couponCodeRequired'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('couponCodeRequired'),
|
||||
});
|
||||
});
|
||||
|
||||
it('should throw an error when coupon code is invalid', async () => {
|
||||
@@ -136,11 +136,11 @@ describe('checkout with subscription', () => {
|
||||
headers,
|
||||
coupon,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('invalidCoupon'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: i18n.t('invalidCoupon'),
|
||||
});
|
||||
cc.validate.restore();
|
||||
});
|
||||
|
||||
|
||||
@@ -57,11 +57,11 @@ describe('checkout', () => {
|
||||
headers,
|
||||
coupon,
|
||||
}, stripe))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
message: 'Amount must be at least 1.',
|
||||
name: 'BadRequest',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ describe('edit subscription', () => {
|
||||
user,
|
||||
groupId: undefined,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('missingSubscription'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('missingSubscription'),
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if a token is not provided', async () => {
|
||||
@@ -55,11 +55,11 @@ describe('edit subscription', () => {
|
||||
user,
|
||||
groupId: undefined,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.id',
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 400,
|
||||
name: 'BadRequest',
|
||||
message: 'Missing req.body.id',
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if the group is not found', async () => {
|
||||
@@ -68,11 +68,11 @@ describe('edit subscription', () => {
|
||||
user,
|
||||
groupId: 'fake-group',
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 404,
|
||||
name: 'NotFound',
|
||||
message: i18n.t('groupNotFound'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 404,
|
||||
name: 'NotFound',
|
||||
message: i18n.t('groupNotFound'),
|
||||
});
|
||||
});
|
||||
|
||||
it('throws an error if user is not the group leader', async () => {
|
||||
@@ -85,11 +85,11 @@ describe('edit subscription', () => {
|
||||
user: nonLeader,
|
||||
groupId,
|
||||
}))
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('onlyGroupLeaderCanManageSubscription'),
|
||||
});
|
||||
.to.eventually.be.rejected.and.to.eql({
|
||||
httpCode: 401,
|
||||
name: 'NotAuthorized',
|
||||
message: i18n.t('onlyGroupLeaderCanManageSubscription'),
|
||||
});
|
||||
});
|
||||
|
||||
describe('success', () => {
|
||||
|
||||
@@ -34,7 +34,7 @@ describe('Stripe - Webhooks', () => {
|
||||
it('logs an error if an unsupported webhook event is passed', async () => {
|
||||
const error = new Error(`Missing handler for Stripe webhook ${eventType}`);
|
||||
await stripePayments.handleWebhooks({requestBody: event}, stripe);
|
||||
expect(logger.error).to.have.been.called.once;
|
||||
expect(logger.error).to.have.been.calledOnce;
|
||||
|
||||
const calledWith = logger.error.getCall(0).args;
|
||||
expect(calledWith[0].message).to.equal(error.message);
|
||||
@@ -43,7 +43,7 @@ describe('Stripe - Webhooks', () => {
|
||||
|
||||
it('retrieves and validates the event from Stripe', async () => {
|
||||
await stripePayments.handleWebhooks({requestBody: event}, stripe);
|
||||
expect(stripe.events.retrieve).to.have.been.called.once;
|
||||
expect(stripe.events.retrieve).to.have.been.calledOnce;
|
||||
expect(stripe.events.retrieve).to.have.been.calledWith(event.id);
|
||||
});
|
||||
});
|
||||
@@ -70,7 +70,7 @@ describe('Stripe - Webhooks', () => {
|
||||
|
||||
await stripePayments.handleWebhooks({requestBody: {}}, stripe);
|
||||
|
||||
expect(stripe.events.retrieve).to.have.been.called.once;
|
||||
expect(stripe.events.retrieve).to.have.been.calledOnce;
|
||||
expect(stripe.customers.del).to.not.have.been.called;
|
||||
expect(payments.cancelSubscription).to.not.have.been.called;
|
||||
stripe.events.retrieve.restore();
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('taskManager', () => {
|
||||
expect(newTask.type).to.equal(testHabit.type);
|
||||
expect(newTask.up).to.equal(testHabit.up);
|
||||
expect(newTask.down).to.equal(testHabit.down);
|
||||
expect(newTask.createdAt).isNotEmtpy;
|
||||
expect(newTask.createdAt).to.exist;
|
||||
});
|
||||
|
||||
it('gets user tasks', async () => {
|
||||
@@ -75,7 +75,7 @@ describe('taskManager', () => {
|
||||
expect(task.type).to.equal(testHabit.type);
|
||||
expect(task.up).to.equal(testHabit.up);
|
||||
expect(task.down).to.equal(testHabit.down);
|
||||
expect(task.createdAt).isNotEmtpy;
|
||||
expect(task.createdAt).to.exist;
|
||||
});
|
||||
|
||||
it('creates group tasks', async () => {
|
||||
@@ -89,7 +89,7 @@ describe('taskManager', () => {
|
||||
expect(newTask.type).to.equal(testHabit.type);
|
||||
expect(newTask.up).to.equal(testHabit.up);
|
||||
expect(newTask.down).to.equal(testHabit.down);
|
||||
expect(newTask.createdAt).isNotEmtpy;
|
||||
expect(newTask.createdAt).to.exist;
|
||||
expect(newTask.group.id).to.equal(group._id);
|
||||
});
|
||||
|
||||
@@ -111,7 +111,7 @@ describe('taskManager', () => {
|
||||
expect(task.type).to.equal(testHabit.type);
|
||||
expect(task.up).to.equal(testHabit.up);
|
||||
expect(task.down).to.equal(testHabit.down);
|
||||
expect(task.createdAt).isNotEmtpy;
|
||||
expect(task.createdAt).to.exist;
|
||||
expect(task.group.id).to.equal(group._id);
|
||||
});
|
||||
|
||||
@@ -126,7 +126,7 @@ describe('taskManager', () => {
|
||||
expect(newTask.type).to.equal(testHabit.type);
|
||||
expect(newTask.up).to.equal(testHabit.up);
|
||||
expect(newTask.down).to.equal(testHabit.down);
|
||||
expect(newTask.createdAt).isNotEmtpy;
|
||||
expect(newTask.createdAt).to.exist;
|
||||
expect(newTask.challenge.id).to.equal(challenge._id);
|
||||
});
|
||||
|
||||
@@ -148,7 +148,7 @@ describe('taskManager', () => {
|
||||
expect(task.type).to.equal(testHabit.type);
|
||||
expect(task.up).to.equal(testHabit.up);
|
||||
expect(task.down).to.equal(testHabit.down);
|
||||
expect(task.createdAt).isNotEmtpy;
|
||||
expect(task.createdAt).to.exist;
|
||||
expect(task.challenge.id).to.equal(challenge._id);
|
||||
});
|
||||
|
||||
@@ -171,7 +171,7 @@ describe('taskManager', () => {
|
||||
expect(syncableTask.updatedAt).to.not.exist;
|
||||
});
|
||||
|
||||
it('moves tasks to a specified position', async() => {
|
||||
it('moves tasks to a specified position', async () => {
|
||||
let order = ['task-id-1', 'task-id-2'];
|
||||
|
||||
moveTask(order, 'task-id-2', 0);
|
||||
|
||||
@@ -23,7 +23,7 @@ describe('cors middleware', () => {
|
||||
'Access-Control-Allow-Headers': 'Content-Type,Accept,Content-Encoding,X-Requested-With,x-api-user,x-api-key,x-client',
|
||||
});
|
||||
expect(res.sendStatus).to.not.have.been.called;
|
||||
expect(next).to.have.been.called.once;
|
||||
expect(next).to.have.been.calledOnce;
|
||||
});
|
||||
|
||||
it('responds immediately if method is OPTIONS', () => {
|
||||
|
||||
@@ -36,12 +36,12 @@ describe('cron middleware', () => {
|
||||
});
|
||||
|
||||
user.save()
|
||||
.then(savedUser => {
|
||||
res.locals.user = savedUser;
|
||||
res.analytics = analyticsService;
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
.then(savedUser => {
|
||||
res.locals.user = savedUser;
|
||||
res.analytics = analyticsService;
|
||||
done();
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
@@ -22,7 +22,7 @@ describe('maintenance mode middleware', () => {
|
||||
|
||||
attachMaintenanceMode(req, res, next);
|
||||
|
||||
expect(next).to.have.been.called.once;
|
||||
expect(next).to.have.been.calledOnce;
|
||||
expect(res.status).to.not.have.been.called;
|
||||
});
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('redirects middleware', () => {
|
||||
|
||||
attachRedirects.forceSSL(req, res, next);
|
||||
|
||||
expect(res.redirect).to.be.notCalled;
|
||||
expect(res.redirect).to.have.not.been.called;
|
||||
});
|
||||
|
||||
it('does not redirect outside of production environments', () => {
|
||||
@@ -57,7 +57,7 @@ describe('redirects middleware', () => {
|
||||
|
||||
attachRedirects.forceSSL(req, res, next);
|
||||
|
||||
expect(res.redirect).to.be.notCalled;
|
||||
expect(res.redirect).to.have.not.been.called;
|
||||
});
|
||||
|
||||
it('does not redirect if base URL is not https', () => {
|
||||
@@ -71,7 +71,7 @@ describe('redirects middleware', () => {
|
||||
|
||||
attachRedirects.forceSSL(req, res, next);
|
||||
|
||||
expect(res.redirect).to.be.notCalled;
|
||||
expect(res.redirect).to.have.not.been.called;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -108,7 +108,7 @@ describe('redirects middleware', () => {
|
||||
|
||||
attachRedirects.forceHabitica(req, res, next);
|
||||
|
||||
expect(res.redirect).to.be.notCalled;
|
||||
expect(res.redirect).to.have.not.been.called;
|
||||
});
|
||||
|
||||
it('does not redirect if env is set to ignore redirection', () => {
|
||||
@@ -125,7 +125,7 @@ describe('redirects middleware', () => {
|
||||
|
||||
attachRedirects.forceHabitica(req, res, next);
|
||||
|
||||
expect(res.redirect).to.be.notCalled;
|
||||
expect(res.redirect).to.have.not.been.called;
|
||||
});
|
||||
|
||||
it('does not redirect if request hostname matches base URL host', () => {
|
||||
@@ -142,7 +142,7 @@ describe('redirects middleware', () => {
|
||||
|
||||
attachRedirects.forceHabitica(req, res, next);
|
||||
|
||||
expect(res.redirect).to.be.notCalled;
|
||||
expect(res.redirect).to.have.not.been.called;
|
||||
});
|
||||
|
||||
it('does not redirect if request is an API URL', () => {
|
||||
@@ -159,7 +159,7 @@ describe('redirects middleware', () => {
|
||||
|
||||
attachRedirects.forceHabitica(req, res, next);
|
||||
|
||||
expect(res.redirect).to.be.notCalled;
|
||||
expect(res.redirect).to.have.not.been.called;
|
||||
});
|
||||
|
||||
it('does not redirect if request method is not GET', () => {
|
||||
@@ -176,7 +176,7 @@ describe('redirects middleware', () => {
|
||||
|
||||
attachRedirects.forceHabitica(req, res, next);
|
||||
|
||||
expect(res.redirect).to.be.notCalled;
|
||||
expect(res.redirect).to.have.not.been.called;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -65,7 +65,7 @@ describe('Challenge Model', () => {
|
||||
|
||||
each(tasksToTest, (taskValue, taskType) => {
|
||||
context(`${taskType}`, () => {
|
||||
beforeEach(async() => {
|
||||
beforeEach(async () => {
|
||||
task = new Tasks[`${taskType}`](Tasks.Task.sanitize(taskValue));
|
||||
task.challenge.id = challenge._id;
|
||||
await task.save();
|
||||
@@ -194,7 +194,7 @@ describe('Challenge Model', () => {
|
||||
});
|
||||
|
||||
expect(syncedTask).to.exist;
|
||||
expect(syncedTask.challenge._id).to.be.empty;
|
||||
expect(syncedTask.challenge._id).to.be.undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -64,7 +64,7 @@ describe('Group Task Methods', () => {
|
||||
|
||||
each(tasksToTest, (taskValue, taskType) => {
|
||||
context(`${taskType}`, () => {
|
||||
beforeEach(async() => {
|
||||
beforeEach(async () => {
|
||||
task = new Tasks[`${taskType}`](Tasks.Task.sanitize(taskValue));
|
||||
task.group.id = guild._id;
|
||||
await task.save();
|
||||
@@ -127,7 +127,7 @@ describe('Group Task Methods', () => {
|
||||
expect(syncedTask.checklist[0].text).to.equal(task.checklist[0].text);
|
||||
});
|
||||
|
||||
describe('syncs updated info', async() => {
|
||||
describe('syncs updated info', async () => {
|
||||
let newMember;
|
||||
|
||||
beforeEach(async () => {
|
||||
@@ -274,7 +274,7 @@ describe('Group Task Methods', () => {
|
||||
|
||||
expect(task.group.assignedUsers).to.not.contain(leader._id);
|
||||
expect(updatedSyncedTask).to.exist;
|
||||
expect(updatedSyncedTask.group._id).to.be.empty;
|
||||
expect(updatedSyncedTask.group._id).to.be.undefined;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('Task Model', () => {
|
||||
|
||||
each(tasksToTest, (taskValue, taskType) => {
|
||||
context(`${taskType}`, () => {
|
||||
beforeEach(async() => {
|
||||
beforeEach(async () => {
|
||||
task = new Tasks[`${taskType}`](Tasks.Task.sanitize(taskValue));
|
||||
task.challenge.id = challenge._id;
|
||||
task.history = generateHistory(396);
|
||||
|
||||
@@ -120,7 +120,7 @@ describe('User Model', () => {
|
||||
expect(User.pushNotification({_id: user._id}, 'CRON', null, 'INVALID_SEEN')).to.eventually.be.rejected;
|
||||
});
|
||||
|
||||
it('adds notifications without data for all given users via static method', async() => {
|
||||
it('adds notifications without data for all given users via static method', async () => {
|
||||
let user = new User();
|
||||
let otherUser = new User();
|
||||
await Bluebird.all([user.save(), otherUser.save()]);
|
||||
|
||||
Reference in New Issue
Block a user