diff --git a/test/api/v2/groups/GET-groups.test.js b/test/api/v2/groups/GET-groups.test.js index ef2915b538..ea881787f7 100644 --- a/test/api/v2/groups/GET-groups.test.js +++ b/test/api/v2/groups/GET-groups.test.js @@ -10,7 +10,7 @@ describe('GET /groups', () => { let user; - before(() => { + before(async () => { let leader, createdGroup; // Set up a world with a mixture of public and private guilds @@ -83,7 +83,7 @@ describe('GET /groups', () => { context('tavern passed in as query', () => { - it('returns only the tavern', () => { + it('returns only the tavern', async () => { return expect(user.get('/groups', null, {type: 'tavern'})) .to.eventually.have.a.lengthOf(1) .and.to.have.deep.property('[0]') @@ -93,7 +93,7 @@ describe('GET /groups', () => { context('party passed in as query', () => { - it('returns only the user\'s party', () => { + it('returns only the user\'s party', async () => { return expect(user.get('/groups', null, {type: 'party'})) .to.eventually.have.a.lengthOf(1) .and.to.have.deep.property('[0]') @@ -103,7 +103,7 @@ describe('GET /groups', () => { context('public passed in as query', () => { - it('returns all public guilds', () => { + it('returns all public guilds', async () => { return expect(user.get('/groups', null, {type: 'public'})) .to.eventually.have.a.lengthOf(NUMBER_OF_PUBLIC_GUILDS); }); @@ -111,7 +111,7 @@ describe('GET /groups', () => { context('guilds passed in as query', () => { - it('returns all guilds user is a part of ', () => { + it('returns all guilds user is a part of ', async () => { return expect(user.get('/groups', null, {type: 'guilds'})) .to.eventually.have.a.lengthOf(NUMBER_OF_USERS_GUILDS); }); diff --git a/test/api/v2/groups/GET-groups_id.test.js b/test/api/v2/groups/GET-groups_id.test.js index e3c9139e20..55fe7fa9c0 100644 --- a/test/api/v2/groups/GET-groups_id.test.js +++ b/test/api/v2/groups/GET-groups_id.test.js @@ -19,7 +19,7 @@ describe('GET /groups/:id', () => { context(`Member of a ${groupType}`, () => { let leader, member, createdGroup; - before(() => { + before(async () => { return createAndPopulateGroup({ members: 30, groupDetails: { @@ -34,7 +34,7 @@ describe('GET /groups/:id', () => { }); }); - it('returns the group object', () => { + it('returns the group object', async () => { return member.get(`/groups/${createdGroup._id}`).then((group) => { expect(group._id).to.eql(createdGroup._id); expect(group.name).to.eql(createdGroup.name); @@ -43,7 +43,7 @@ describe('GET /groups/:id', () => { }); }); - it('transforms members array to an array of user objects', () => { + it('transforms members array to an array of user objects', async () => { return member.get(`/groups/${createdGroup._id}`).then((group) => { let member = group.members[0]; expect(member._id).to.exist; @@ -54,7 +54,7 @@ describe('GET /groups/:id', () => { }); }); - it('transforms leader id to leader object', () => { + it('transforms leader id to leader object', async () => { return member.get(`/groups/${createdGroup._id}`).then((group) => { expect(group.leader._id).to.eql(leader._id); expect(group.leader.profile.name).to.eql(leader.profile.name); @@ -65,7 +65,7 @@ describe('GET /groups/:id', () => { }); }); - it('includes the user in the members list', () => { + it('includes the user in the members list', async () => { return member.get(`/groups/${createdGroup._id}`).then((group) => { let members = group.members; let userInGroup = find(members, (user) => { @@ -123,7 +123,7 @@ describe('GET /groups/:id', () => { flagCount: 3, }; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { name: 'test guild', @@ -145,13 +145,13 @@ describe('GET /groups/:id', () => { context('non-admin', () => { let nonAdmin; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((user) => { nonAdmin = user; }); }); - it('does not include messages with a flag count of 2 or greater', () => { + it('does not include messages with a flag count of 2 or greater', async () => { return nonAdmin.get(`/groups/${group._id}`).then((_group) => { expect(_group.chat).to.have.lengthOf(3); expect(_group.chat[0].id).to.eql(chat1.id); @@ -160,7 +160,7 @@ describe('GET /groups/:id', () => { }); }); - it('does not include user ids in flags object', () => { + it('does not include user ids in flags object', async () => { return nonAdmin.get(`/groups/${group._id}`).then((_group) => { let chatWithOneFlag = _group.chat[2]; expect(chatWithOneFlag.id).to.eql(chat3.id); @@ -173,7 +173,7 @@ describe('GET /groups/:id', () => { context('admin', () => { let admin; - beforeEach(() => { + beforeEach(async () => { return generateUser({ 'contributor.admin': true, }).then((user) => { @@ -181,7 +181,7 @@ describe('GET /groups/:id', () => { }); }); - it('includes all messages', () => { + it('includes all messages', async () => { return admin.get(`/groups/${group._id}`).then((_group) => { expect(_group.chat).to.have.lengthOf(5); expect(_group.chat[0].id).to.eql(chat1.id); @@ -192,7 +192,7 @@ describe('GET /groups/:id', () => { }); }); - it('includes user ids in flags object', () => { + it('includes user ids in flags object', async () => { return admin.get(`/groups/${group._id}`).then((_group) => { let chatWithOneFlag = _group.chat[2]; expect(chatWithOneFlag.id).to.eql(chat3.id); @@ -206,7 +206,7 @@ describe('GET /groups/:id', () => { context('Non-member of a public guild', () => { let leader, nonMember, createdGroup; - before(() => { + before(async () => { return createAndPopulateGroup({ members: 1, groupDetails: { @@ -223,7 +223,7 @@ describe('GET /groups/:id', () => { }); }); - it('returns the group object for a non-member', () => { + it('returns the group object for a non-member', async () => { return nonMember.get(`/groups/${createdGroup._id}`) .then((group) => { expect(group._id).to.eql(createdGroup._id); @@ -233,7 +233,7 @@ describe('GET /groups/:id', () => { }); }); - it('does not include user in members list', () => { + it('does not include user in members list', async () => { return nonMember.get(`/groups/${createdGroup._id}`).then((group) => { let userInGroup = find(group.members, (user) => { return nonMember._id === user._id; @@ -246,7 +246,7 @@ describe('GET /groups/:id', () => { context('Private Guilds', () => { let leader, nonMember, createdGroup; - before(() => { + before(async () => { return createAndPopulateGroup({ members: 1, groupDetails: { @@ -263,7 +263,7 @@ describe('GET /groups/:id', () => { }); }); - it('does not return the group object for a non-member', () => { + it('does not return the group object for a non-member', async () => { return expect(nonMember.get(`/groups/${createdGroup._id}`)) .to.eventually.be.rejected.and.eql({ code: 404, @@ -275,7 +275,7 @@ describe('GET /groups/:id', () => { context('Non-member of a party', () => { let leader, nonMember, createdGroup; - before(() => { + before(async () => { return createAndPopulateGroup({ members: 1, groupDetails: { @@ -292,7 +292,7 @@ describe('GET /groups/:id', () => { }); }); - it('does not return the group object for a non-member', () => { + it('does not return the group object for a non-member', async () => { return expect(nonMember.get(`/groups/${createdGroup._id}`)) .to.eventually.be.rejected.and.eql({ code: 404, @@ -304,7 +304,7 @@ describe('GET /groups/:id', () => { context('Member of a party', () => { let leader, member, createdGroup; - before(() => { + before(async () => { return createAndPopulateGroup({ members: 1, groupDetails: { @@ -319,7 +319,7 @@ describe('GET /groups/:id', () => { }); }); - it('returns the user\'s party if an id of "party" is passed in', () => { + it('returns the user\'s party if an id of "party" is passed in', async () => { return member.get('/groups/party') .then((group) => { expect(group._id).to.eql(createdGroup._id); @@ -333,13 +333,13 @@ describe('GET /groups/:id', () => { context('Non-existent group', () => { let user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((_user) => { user = _user; }); }); - it('returns error if group does not exist', () => { + it('returns error if group does not exist', async () => { return expect(user.get('/groups/group-that-does-not-exist')) .to.eventually.be.rejected.and.eql({ code: 404, diff --git a/test/api/v2/groups/POST-groups.test.js b/test/api/v2/groups/POST-groups.test.js index 90c3cbfcaa..c898915cff 100644 --- a/test/api/v2/groups/POST-groups.test.js +++ b/test/api/v2/groups/POST-groups.test.js @@ -8,11 +8,11 @@ describe('POST /groups', () => { context('All groups', () => { let leader; - beforeEach(async () => { + beforeEach(async async () => { leader = await generateUser(); }); - xit('returns defaults? (TODO: it\'s possible to create a group without a type. Should the group default to party? Should we require type to be set?', () => { + xit('returns defaults? (TODO: it\'s possible to create a group without a type. Should the group default to party? Should we require type to be set?', async () => { return leader.post('/groups').then((group) => { expect(group._id).to.exist; expect(group.name).to.eql(`${leader.profile.name}'s group`); @@ -21,7 +21,7 @@ describe('POST /groups', () => { }); }); - it('returns a group object', async () => { + it('returns a group object', async async () => { let group = await leader.post('/groups', { name: 'Test Group', type: 'party', @@ -39,7 +39,7 @@ describe('POST /groups', () => { expect(group.memberCount).to.eql(1); }); - it('returns a populated members array', async () => { + it('returns a populated members array', async async () => { let party = await leader.post('/groups', { type: 'party', }); @@ -55,11 +55,11 @@ describe('POST /groups', () => { context('Parties', () => { let leader; - beforeEach(async () => { + beforeEach(async async () => { leader = await generateUser(); }); - it('allows party creation without gems', async () => { + it('allows party creation without gems', async async () => { let party = await leader.post('/groups', { type: 'party', }); @@ -67,7 +67,7 @@ describe('POST /groups', () => { expect(party._id).to.exist; }); - it('prevents party creation if user is already in party', async () => { + it('prevents party creation if user is already in party', async async () => { let party = await generateGroup(leader, { type: 'party', }); @@ -78,7 +78,7 @@ describe('POST /groups', () => { }); }); - xit('prevents creating a public party. TODO: it is possible to create a public party. Should we send back an error? Automatically switch the privacy to private?', () => { + xit('prevents creating a public party. TODO: it is possible to create a public party. Should we send back an error? Automatically switch the privacy to private?', async () => { return expect(leader.post('/groups', { type: 'party', privacy: 'public', @@ -92,13 +92,13 @@ describe('POST /groups', () => { context('Guilds', () => { let leader; - beforeEach(async () => { + beforeEach(async async () => { leader = await generateUser({ balance: 2, }); }); - it('prevents guild creation when user does not have enough gems', async () => { + it('prevents guild creation when user does not have enough gems', async async () => { let userWithoutGems = await generateUser({ balance: 0.75, }); @@ -109,7 +109,7 @@ describe('POST /groups', () => { }); }); - it('can create a public guild', async () => { + it('can create a public guild', async async () => { let guild = await leader.post('/groups', { type: 'guild', privacy: 'public', @@ -118,7 +118,7 @@ describe('POST /groups', () => { expect(guild.leader).to.eql(leader._id); }); - it('can create a private guild', async () => { + it('can create a private guild', async async () => { let privateGuild = await leader.post('/groups', { type: 'guild', privacy: 'private', @@ -127,7 +127,7 @@ describe('POST /groups', () => { expect(privateGuild.leader).to.eql(leader._id); }); - it('deducts gems from user and adds them to guild bank', async () => { + it('deducts gems from user and adds them to guild bank', async async () => { let guild = await leader.post('/groups', { type: 'guild', privacy: 'private', diff --git a/test/api/v2/groups/POST-groups_id.test.js b/test/api/v2/groups/POST-groups_id.test.js index d96d1c4088..fd628505d1 100644 --- a/test/api/v2/groups/POST-groups_id.test.js +++ b/test/api/v2/groups/POST-groups_id.test.js @@ -9,7 +9,7 @@ describe('POST /groups/:id', () => { context('user is not the leader of the group', () => { let user, otherUser, groupUserDoesNotOwn; - beforeEach(() => { + beforeEach(async () => { return Promise.all([ generateUser({ balance: 10 }), generateUser({ balance: 10 }), @@ -28,7 +28,7 @@ describe('POST /groups/:id', () => { }); }); - it('does not allow user to update group', () => { + it('does not allow user to update group', async () => { return expect(user.post(`/groups/${groupUserDoesNotOwn._id}`, { name: 'Change' })).to.eventually.be.rejected.and.eql({ @@ -41,7 +41,7 @@ describe('POST /groups/:id', () => { context('user is the leader of the group', () => { let user, usersGroup; - beforeEach(() => { + beforeEach(async () => { return generateUser({ balance: 10, }).then((_user) => { @@ -57,7 +57,7 @@ describe('POST /groups/:id', () => { }); }); - it('allows user to update group', () => { + it('allows user to update group', async () => { return user.post(`/groups/${usersGroup._id}`, { name: 'New Group Title', description: 'New group description', diff --git a/test/api/v2/groups/POST-groups_id_join.test.js b/test/api/v2/groups/POST-groups_id_join.test.js index 6613dabc78..4016ea1853 100644 --- a/test/api/v2/groups/POST-groups_id_join.test.js +++ b/test/api/v2/groups/POST-groups_id_join.test.js @@ -19,7 +19,7 @@ describe('POST /groups/:id/join', () => { context(`user has invitation to a ${groupType}`, () => { let group, invitee; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: data.type, @@ -32,7 +32,7 @@ describe('POST /groups/:id/join', () => { }); }); - it(`allows user to join a ${groupType}`, () => { + it(`allows user to join a ${groupType}`, async () => { return invitee.post(`/groups/${group._id}/join`).then((res) => { return invitee.get(`/groups/${group._id}`); }).then((_group) => { @@ -54,7 +54,7 @@ describe('POST /groups/:id/join', () => { context(`user does not have an invitation to a ${groupType}`, () => { let group, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: data.type, @@ -68,7 +68,7 @@ describe('POST /groups/:id/join', () => { }); }); - it(`does not allow user to join a ${groupType}`, () => { + it(`does not allow user to join a ${groupType}`, async () => { return expect(user.post(`/groups/${group._id}/join`).then((res) => { return user.get(`/groups/${group._id}`); })).to.eventually.be.rejected.and.eql({ @@ -82,7 +82,7 @@ describe('POST /groups/:id/join', () => { context('user does not have an invitation to a public group', () => { let group, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -96,7 +96,7 @@ describe('POST /groups/:id/join', () => { }); }); - it('allows user to join a public guild', () => { + it('allows user to join a public guild', async () => { return user.post(`/groups/${group._id}/join`).then((res) => { return user.get(`/groups/${group._id}`); }).then((_group) => { @@ -113,7 +113,7 @@ describe('POST /groups/:id/join', () => { context('public guild has no leader', () => { let user, group; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { name: 'test guild', @@ -130,7 +130,7 @@ describe('POST /groups/:id/join', () => { }); }); - it('makes the joining user the leader', () => { + it('makes the joining user the leader', async () => { return expect(user.post(`/groups/${group._id}/join`).then((result) => { return user.get(`/groups/${group._id}`); })).to.eventually.have.deep.property('leader._id', user._id); diff --git a/test/api/v2/groups/POST-groups_id_leave.test.js b/test/api/v2/groups/POST-groups_id_leave.test.js index 946cca406d..31bdbf2c8b 100644 --- a/test/api/v2/groups/POST-groups_id_leave.test.js +++ b/test/api/v2/groups/POST-groups_id_leave.test.js @@ -15,7 +15,7 @@ describe('POST /groups/:id/leave', () => { context('user is a non-leader member of a guild', () => { let user, group; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ members: 3, groupDetails: { @@ -29,7 +29,7 @@ describe('POST /groups/:id/leave', () => { }); }); - it('leaves the group', () => { + it('leaves the group', async () => { return user.post(`/groups/${group._id}/leave`).then((result) => { return user.get(`/groups/${group._id}`); }).then((group) => { @@ -44,7 +44,7 @@ describe('POST /groups/:id/leave', () => { context('user is the last member of a public guild', () => { let user, group; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { name: 'test guild', @@ -57,7 +57,7 @@ describe('POST /groups/:id/leave', () => { }); }); - it('leaves the group accessible', () => { + it('leaves the group accessible', async () => { return expect(user.post(`/groups/${group._id}/leave`).then((result) => { return user.get(`/groups/${group._id}`); })).to.eventually.have.property('_id', group._id); @@ -67,7 +67,7 @@ describe('POST /groups/:id/leave', () => { context('user is the last member of a private group', () => { let user, group; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { name: 'test guild', @@ -80,7 +80,7 @@ describe('POST /groups/:id/leave', () => { }); }); - it('group is deleted', () => { + it('group is deleted', async () => { return expect(user.post(`/groups/${group._id}/leave`).then((result) => { return checkExistence('groups', group._id); })).to.eventually.eql(false); @@ -90,7 +90,7 @@ describe('POST /groups/:id/leave', () => { context('user is the last member of a private group with pending invites', () => { let user, invitee1, invitee2, group; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ invites: 2, groupDetails: { @@ -106,7 +106,7 @@ describe('POST /groups/:id/leave', () => { }); }); - it('deletes the group invitations from users', () => { + it('deletes the group invitations from users', async () => { return user.post(`/groups/${group._id}/leave`).then((result) => { return Promise.all([ expect(invitee1.get(`/user`)) @@ -123,7 +123,7 @@ describe('POST /groups/:id/leave', () => { context('user is the last member of a party with pending invites', () => { let user, invitee1, invitee2, group; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ invites: 2, groupDetails: { @@ -139,7 +139,7 @@ describe('POST /groups/:id/leave', () => { }); }); - it('deletes the group invitations from users', () => { + it('deletes the group invitations from users', async () => { return user.post(`/groups/${group._id}/leave`).then((result) => { return Promise.all([ expect(invitee1.get(`/user`)) diff --git a/test/api/v2/groups/POST-groups_id_removeMember.test.js b/test/api/v2/groups/POST-groups_id_removeMember.test.js index 27214b8050..9cbd090222 100644 --- a/test/api/v2/groups/POST-groups_id_removeMember.test.js +++ b/test/api/v2/groups/POST-groups_id_removeMember.test.js @@ -18,7 +18,7 @@ describe('POST /groups/:id/removeMember', () => { context('user is the leader of a guild', () => { let leader, member, group; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ members: 1, groupDetails: { @@ -33,7 +33,7 @@ describe('POST /groups/:id/removeMember', () => { }); }); - it('does not allow leader to remove themselves', () => { + it('does not allow leader to remove themselves', async () => { return expect(leader.post(`/groups/${group._id}/removeMember`, null, { uuid: leader._id, })).to.eventually.be.rejected.and.eql({ @@ -42,7 +42,7 @@ describe('POST /groups/:id/removeMember', () => { }); }); - it('can remove other members of guild', () => { + it('can remove other members of guild', async () => { return leader.post(`/groups/${group._id}/removeMember`, null, { uuid: member._id, }).then((res) => { diff --git a/test/api/v2/groups/chat/DELETE-groups_id_chat.test.js b/test/api/v2/groups/chat/DELETE-groups_id_chat.test.js index c097a6454b..964159c1bf 100644 --- a/test/api/v2/groups/chat/DELETE-groups_id_chat.test.js +++ b/test/api/v2/groups/chat/DELETE-groups_id_chat.test.js @@ -7,7 +7,7 @@ import { describe('DELETE /groups/:id/chat', () => { let group, message, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -23,7 +23,7 @@ describe('DELETE /groups/:id/chat', () => { }); }); - it('deletes a message', () => { + it('deletes a message', async () => { return user.del(`/groups/${group._id}/chat/${message.id}`).then((res) => { return user.get(`/groups/${group._id}/chat/`); }).then((messages) => { @@ -31,7 +31,7 @@ describe('DELETE /groups/:id/chat', () => { }); }); - it('returns an error is message does not exist', () => { + it('returns an error is message does not exist', async () => { return expect(user.del(`/groups/${group._id}/chat/some-fake-id`)).to.eventually.be.rejected.and.eql({ code: 404, text: t('messageGroupChatNotFound'), diff --git a/test/api/v2/groups/chat/GET-groups_id_chat.test.js b/test/api/v2/groups/chat/GET-groups_id_chat.test.js index f5a440a1cb..fac510bb03 100644 --- a/test/api/v2/groups/chat/GET-groups_id_chat.test.js +++ b/test/api/v2/groups/chat/GET-groups_id_chat.test.js @@ -9,7 +9,7 @@ describe('GET /groups/:id/chat', () => { context('group with multiple messages', () => { let group, member, message1, message2, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -31,7 +31,7 @@ describe('GET /groups/:id/chat', () => { }); }); - it('gets messages', () => { + it('gets messages', async () => { return user.get(`/groups/${group._id}/chat`).then((messages) => { expect(messages).to.have.length(2); diff --git a/test/api/v2/groups/chat/POST-groups_id_chat.test.js b/test/api/v2/groups/chat/POST-groups_id_chat.test.js index d476643ea6..781d5e7bc4 100644 --- a/test/api/v2/groups/chat/POST-groups_id_chat.test.js +++ b/test/api/v2/groups/chat/POST-groups_id_chat.test.js @@ -8,7 +8,7 @@ describe('POST /groups/:id/chat', () => { let group, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -20,7 +20,7 @@ describe('POST /groups/:id/chat', () => { }); }); - it('creates a chat message', () => { + it('creates a chat message', async () => { return user.post(`/groups/${group._id}/chat`, null, { message: 'Test Message', }).then((res) => { @@ -33,7 +33,7 @@ describe('POST /groups/:id/chat', () => { }); }); - it('does not post an empty message', () => { + it('does not post an empty message', async () => { return expect(user.post(`/groups/${group._id}/chat`, null, { message: '', })).to.eventually.be.rejected.and.eql({ diff --git a/test/api/v2/groups/chat/POST-groups_id_chat_id_clearflags.test.js b/test/api/v2/groups/chat/POST-groups_id_chat_id_clearflags.test.js index 8b98ce98f6..7cb5f20c59 100644 --- a/test/api/v2/groups/chat/POST-groups_id_chat_id_clearflags.test.js +++ b/test/api/v2/groups/chat/POST-groups_id_chat_id_clearflags.test.js @@ -7,7 +7,7 @@ import { describe('POST /groups/:id/chat/:id/clearflags', () => { let group; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -28,13 +28,13 @@ describe('POST /groups/:id/chat/:id/clearflags', () => { context('non admin', () => { let nonadmin; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((user) => { nonadmin = user; }); }); - it('cannot clear flags', () => { + it('cannot clear flags', async () => { return expect(nonadmin.post(`/groups/${group._id}/chat/message-to-clear/clearflags`)) .to.eventually.be.rejected.and.eql({ code: 401, @@ -46,7 +46,7 @@ describe('POST /groups/:id/chat/:id/clearflags', () => { context('admin', () => { let admin; - beforeEach(() => { + beforeEach(async () => { return generateUser({ 'contributor.admin': true, }).then((user) => { @@ -54,7 +54,7 @@ describe('POST /groups/:id/chat/:id/clearflags', () => { }); }); - it('clears flags', () => { + it('clears flags', async () => { return admin.post(`/groups/${group._id}/chat/message-to-clear/clearflags`).then((res) => { return admin.get(`/groups/${group._id}/chat`); }).then((messages) => { @@ -62,7 +62,7 @@ describe('POST /groups/:id/chat/:id/clearflags', () => { }); }); - it('leaves old flags on the flag object', () => { + it('leaves old flags on the flag object', async () => { return admin.post(`/groups/${group._id}/chat/message-to-clear/clearflags`).then((res) => { return admin.get(`/groups/${group._id}/chat`); }).then((messages) => { @@ -70,7 +70,7 @@ describe('POST /groups/:id/chat/:id/clearflags', () => { }); }); - it('returns error if message does not exist', () => { + it('returns error if message does not exist', async () => { return expect(admin.post(`/groups/${group._id}/chat/non-existant-message/clearflags`)) .to.eventually.be.rejected.and.eql({ code: 404, @@ -82,7 +82,7 @@ describe('POST /groups/:id/chat/:id/clearflags', () => { context('admin user, group with multiple messages', () => { let admin, author, group, member; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((user) => { author = user; @@ -109,7 +109,7 @@ describe('POST /groups/:id/chat/:id/clearflags', () => { }); }); - it('changes only the message that is flagged', () => { + it('changes only the message that is flagged', async () => { return admin.post(`/groups/${group._id}/chat/message-to-unflag/clearflags`).then((messages) => { return admin.get(`/groups/${group._id}/chat`); }).then((messages) => { diff --git a/test/api/v2/groups/chat/POST-groups_id_chat_id_flag.test.js b/test/api/v2/groups/chat/POST-groups_id_chat_id_flag.test.js index d640c8035e..076f05321f 100644 --- a/test/api/v2/groups/chat/POST-groups_id_chat_id_flag.test.js +++ b/test/api/v2/groups/chat/POST-groups_id_chat_id_flag.test.js @@ -9,7 +9,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { context('another member\'s message', () => { let group, member, message, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -27,7 +27,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { }); }); - it('flags message', () => { + it('flags message', async () => { return user.post(`/groups/${group._id}/chat/${message.id}/flag`).then((messages) => { return user.get(`/groups/${group._id}/chat`); }).then((messages) => { @@ -36,7 +36,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { }); }); - it('cannot flag the same message twice', () => { + it('cannot flag the same message twice', async () => { return expect(user.post(`/groups/${group._id}/chat/${message.id}/flag`).then((messages) => { return user.post(`/groups/${group._id}/chat/${message.id}/flag`); })).to.eventually.be.rejected.and.eql({ @@ -49,7 +49,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { context('own message', () => { let group, message, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -66,7 +66,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { }); }); - it('cannot flag message', () => { + it('cannot flag message', async () => { return expect(user.post(`/groups/${group._id}/chat/${message.id}/flag`)) .to.eventually.be.rejected.and.eql({ code: 401, @@ -78,7 +78,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { context('nonexistant message', () => { let group, message, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -90,7 +90,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { }); }); - it('returns error', () => { + it('returns error', async () => { return expect(user.post(`/groups/${group._id}/chat/non-existant-message/flag`)) .to.eventually.be.rejected.and.eql({ code: 404, @@ -102,7 +102,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { context('group with multiple messages', () => { let admin, author, group, member, message, user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((user) => { author = user; @@ -131,7 +131,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { }); }); - it('changes only the message that is flagged', () => { + it('changes only the message that is flagged', async () => { return user.post(`/groups/${group._id}/chat/message-to-be-flagged/flag`).then((messages) => { return admin.get(`/groups/${group._id}/chat`); }).then((messages) => { @@ -160,7 +160,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { context('admin flagging a message', () => { let group, member, message, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -182,7 +182,7 @@ describe('POST /groups/:id/chat/:id/flag', () => { }); }); - it('sets flagCount to 5', () => { + it('sets flagCount to 5', async () => { return user.post(`/groups/${group._id}/chat/${message.id}/flag`).then((messages) => { return user.get(`/groups/${group._id}/chat`); }).then((messages) => { diff --git a/test/api/v2/groups/chat/POST-groups_id_chat_id_like.test.js b/test/api/v2/groups/chat/POST-groups_id_chat_id_like.test.js index bbe06bb1fb..7b5623d7a0 100644 --- a/test/api/v2/groups/chat/POST-groups_id_chat_id_like.test.js +++ b/test/api/v2/groups/chat/POST-groups_id_chat_id_like.test.js @@ -9,7 +9,7 @@ describe('POST /groups/:id/chat/:id/like', () => { context('another member\'s message', () => { let group, member, message, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -27,14 +27,14 @@ describe('POST /groups/:id/chat/:id/like', () => { }); }); - it('likes message', () => { + it('likes message', async () => { return user.post(`/groups/${group._id}/chat/${message.id}/like`).then((messages) => { let message = messages[0]; expect(message.likes[user._id]).to.eql(true); }); }); - it('returns the message object', () => { + it('returns the message object', async () => { return user.post(`/groups/${group._id}/chat/${message.id}/like`).then((messages) => { let message = messages[0]; expect(message.text).to.eql('Group member message'); @@ -47,7 +47,7 @@ describe('POST /groups/:id/chat/:id/like', () => { context('own message', () => { let group, message, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -64,7 +64,7 @@ describe('POST /groups/:id/chat/:id/like', () => { }); }); - it('cannot like message', () => { + it('cannot like message', async () => { return expect(user.post(`/groups/${group._id}/chat/${message.id}/like`)) .to.eventually.be.rejected.and.eql({ code: 401, @@ -76,7 +76,7 @@ describe('POST /groups/:id/chat/:id/like', () => { context('group with multiple messages', () => { let admin, author, group, member, message, user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((user) => { author = user; @@ -105,7 +105,7 @@ describe('POST /groups/:id/chat/:id/like', () => { }); }); - it('changes only the message that is liked', () => { + it('changes only the message that is liked', async () => { return user.post(`/groups/${group._id}/chat/message-to-be-liked/like`).then((messages) => { return admin.get(`/groups/${group._id}/chat`); }).then((messages) => { @@ -134,7 +134,7 @@ describe('POST /groups/:id/chat/:id/like', () => { context('nonexistant message', () => { let group, message, user; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -146,7 +146,7 @@ describe('POST /groups/:id/chat/:id/like', () => { }); }); - it('returns error', () => { + it('returns error', async () => { return expect(user.post(`/groups/${group._id}/chat/non-existant-message/like`)) .to.eventually.be.rejected.and.eql({ code: 404, diff --git a/test/api/v2/register/POST-register.test.js b/test/api/v2/register/POST-register.test.js index a4d1987002..a49d4aa67d 100644 --- a/test/api/v2/register/POST-register.test.js +++ b/test/api/v2/register/POST-register.test.js @@ -9,7 +9,7 @@ import { each } from 'lodash'; describe('POST /register', () => { context('username and email are free', () => { - it('registers a new user', () => { + it('registers a new user', async () => { let api = requester(); let username = generateRandomUserName(); let email = `${username}@example.com`; @@ -27,7 +27,7 @@ describe('POST /register', () => { }); }); - it('requires password and confirmPassword to match', () => { + it('requires password and confirmPassword to match', async () => { let api = requester(); let username = generateRandomUserName(); let email = `${username}@example.com`; @@ -45,7 +45,7 @@ describe('POST /register', () => { }); }); - it('requires a username', () => { + it('requires a username', async () => { let api = requester(); let email = `${generateRandomUserName()}@example.com`; let password = 'password'; @@ -61,7 +61,7 @@ describe('POST /register', () => { }); }); - it('requires an email', () => { + it('requires an email', async () => { let api = requester(); let username = generateRandomUserName(); let password = 'password'; @@ -77,7 +77,7 @@ describe('POST /register', () => { }); }); - it('requires a password', () => { + it('requires a password', async () => { let api = requester(); let username = generateRandomUserName(); let email = `${username}@example.com`; @@ -96,7 +96,7 @@ describe('POST /register', () => { context('login is already taken', () => { let username, email; - beforeEach(() => { + beforeEach(async () => { username = generateRandomUserName(); email = `${username}@example.com`; return generateUser({ @@ -106,7 +106,7 @@ describe('POST /register', () => { }); }); - it('rejects if username is already taken', () => { + it('rejects if username is already taken', async () => { let api = requester(); let uniqueEmail = `${generateRandomUserName()}@exampe.com`; let password = 'password'; @@ -122,7 +122,7 @@ describe('POST /register', () => { }); }); - it('rejects if email is already taken', () => { + it('rejects if email is already taken', async () => { let api = requester(); let uniqueUsername = generateRandomUserName(); let password = 'password'; @@ -142,14 +142,14 @@ describe('POST /register', () => { context('successful login via api', () => { let api, username, email, password; - beforeEach(() => { + beforeEach(async () => { api = requester(); username = generateRandomUserName(); email = `${username}@example.com`; password = 'password'; }); - it('sets all site tour values to -2 (already seen)', () => { + it('sets all site tour values to -2 (already seen)', async () => { return api.post('/register', { username: username, email: email, @@ -164,7 +164,7 @@ describe('POST /register', () => { }); }); - it('populates user with default todos, not no other task types', () => { + it('populates user with default todos, not no other task types', async () => { return api.post('/register', { username: username, email: email, @@ -178,7 +178,7 @@ describe('POST /register', () => { }); }); - it('populates user with default tags', () => { + it('populates user with default tags', async () => { return api.post('/register', { username: username, email: email, @@ -193,14 +193,14 @@ describe('POST /register', () => { context('successful login with habitica-web header', () => { let api, username, email, password; - beforeEach(() => { + beforeEach(async () => { api = requester({}, {'x-client': 'habitica-web'}); username = generateRandomUserName(); email = `${username}@example.com`; password = 'password'; }); - it('sets all common tutorial flags to true', () => { + it('sets all common tutorial flags to true', async () => { return api.post('/register', { username: username, email: email, @@ -215,7 +215,7 @@ describe('POST /register', () => { }); }); - it('populates user with default todos, habits, and rewards', () => { + it('populates user with default todos, habits, and rewards', async () => { return api.post('/register', { username: username, email: email, @@ -229,7 +229,7 @@ describe('POST /register', () => { }); }); - it('populates user with default tags', () => { + it('populates user with default tags', async () => { return api.post('/register', { username: username, email: email, @@ -244,14 +244,14 @@ describe('POST /register', () => { context('successful login with habitica-android header', () => { let api, username, email, password; - beforeEach(() => { + beforeEach(async () => { api = requester({}, {'x-client': 'habitica-android'}); username = generateRandomUserName(); email = `${username}@example.com`; password = 'password'; }); - it('sets all common tutorial flags to true', () => { + it('sets all common tutorial flags to true', async () => { return api.post('/register', { username: username, email: email, @@ -266,7 +266,7 @@ describe('POST /register', () => { }); }); - it('populates user with default todos, habits, and rewards', () => { + it('populates user with default todos, habits, and rewards', async () => { return api.post('/register', { username: username, email: email, @@ -280,7 +280,7 @@ describe('POST /register', () => { }); }); - it('populates user with default tags', () => { + it('populates user with default tags', async () => { return api.post('/register', { username: username, email: email, diff --git a/test/api/v2/status/GET-status.test.js b/test/api/v2/status/GET-status.test.js index 2ac91b55e8..6e9974537c 100644 --- a/test/api/v2/status/GET-status.test.js +++ b/test/api/v2/status/GET-status.test.js @@ -1,7 +1,7 @@ import {requester} from '../../../helpers/api-integration.helper'; describe('Status', () => { - it('returns a status of up when server is up', () => { + it('returns a status of up when server is up', async () => { let api = requester(); return expect(api.get('/status')) diff --git a/test/api/v2/user/DELETE-user.test.js b/test/api/v2/user/DELETE-user.test.js index 49e0b869fb..e035aec072 100644 --- a/test/api/v2/user/DELETE-user.test.js +++ b/test/api/v2/user/DELETE-user.test.js @@ -10,13 +10,13 @@ import { find } from 'lodash'; describe('DELETE /user', () => { let user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((usr) => { user = usr; }); }); - it('deletes the user', () => { + it('deletes the user', async () => { return expect(user.del('/user').then((fetchedUser) => { return checkExistence('users', user._id); })).to.eventually.eql(false); @@ -29,7 +29,7 @@ describe('DELETE /user', () => { context('last member of a party', () => { let party; - beforeEach(() => { + beforeEach(async () => { return generateGroup(user, { type: 'party', privacy: 'private' @@ -38,7 +38,7 @@ describe('DELETE /user', () => { }); }); - it('deletes party when user is the only member', () => { + it('deletes party when user is the only member', async () => { return expect(user.del('/user').then((result) => { return checkExistence('groups', party._id); })).to.eventually.eql(false); @@ -48,7 +48,7 @@ describe('DELETE /user', () => { context('last member of a private guild', () => { let guild; - beforeEach(() => { + beforeEach(async () => { return generateGroup(user, { type: 'guild', privacy: 'private' @@ -57,7 +57,7 @@ describe('DELETE /user', () => { }); }); - it('deletes guild when user is the only member', () => { + it('deletes guild when user is the only member', async () => { return expect(user.del('/user').then((result) => { return checkExistence('groups', guild._id); })).to.eventually.eql(false); @@ -67,7 +67,7 @@ describe('DELETE /user', () => { context('groups user is leader of', () => { let group, oldLeader, newLeader; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -81,7 +81,7 @@ describe('DELETE /user', () => { }); }); - it('chooses new group leader for any group user was the leader of', () => { + it('chooses new group leader for any group user was the leader of', async () => { return oldLeader.del('/user').then((res) => { return newLeader.get(`/groups/${group._id}`); }).then((guild) => { @@ -94,7 +94,7 @@ describe('DELETE /user', () => { context('groups user is a part of', () => { let group1, group2, userToDelete, otherUser; - beforeEach(() => { + beforeEach(async () => { return generateUser({ balance: 10, }).then((user) => { @@ -122,7 +122,7 @@ describe('DELETE /user', () => { }); }); - it('removes user from all groups user was a part of', () => { + it('removes user from all groups user was a part of', async () => { return userToDelete.del('/user').then((res) => { return otherUser.get(`/groups/${group1._id}`); }).then((fetchedGroup1) => { @@ -145,7 +145,7 @@ describe('DELETE /user', () => { context('pending invitation to group', () => { let group, userToDelete, otherUser; - beforeEach(() => { + beforeEach(async () => { return createAndPopulateGroup({ groupDetails: { type: 'guild', @@ -160,7 +160,7 @@ describe('DELETE /user', () => { }); }); - it('removes invitations from groups', () => { + it('removes invitations from groups', async () => { return userToDelete.del('/user').then((res) => { return otherUser.get(`/groups/${group._id}`); }).then((fetchedGroup) => { diff --git a/test/api/v2/user/GET-user.test.js b/test/api/v2/user/GET-user.test.js index 4a245bf58a..5544f0f7c6 100644 --- a/test/api/v2/user/GET-user.test.js +++ b/test/api/v2/user/GET-user.test.js @@ -5,24 +5,24 @@ import { describe('GET /user', () => { let user; - before(async () => { + before(async async () => { let usr = await generateUser(); user = await usr.get('/user'); }); - it('gets the user object', () => { + it('gets the user object', async () => { expect(user._id).to.eql(user._id); expect(user.auth.local.username).to.eql(user.auth.local.username); expect(user.todos).to.eql(user.todos); expect(user.items).to.eql(user.items); }); - it('does not include password information', () => { + it('does not include password information', async () => { expect(user.auth.local.hashed_password).to.not.exist expect(user.auth.local.salt).to.not.exist }); - it('does not include api token', () => { + it('does not include api token', async () => { expect(user.apiToken).to.not.exist }); }); diff --git a/test/api/v2/user/GET-user_tags.test.js b/test/api/v2/user/GET-user_tags.test.js index 9e0e23dbc1..92a6e3d6f3 100644 --- a/test/api/v2/user/GET-user_tags.test.js +++ b/test/api/v2/user/GET-user_tags.test.js @@ -5,13 +5,13 @@ import { describe('GET /user/tags', () => { let user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((usr) => { user = usr; }); }); - it('gets the user\'s tags', () => { + it('gets the user\'s tags', async () => { return expect(user.get('/user/tags')) .to.eventually.eql(user.tags); }); diff --git a/test/api/v2/user/GET-user_tags_id.test.js b/test/api/v2/user/GET-user_tags_id.test.js index 6cdda69949..3e185f07ae 100644 --- a/test/api/v2/user/GET-user_tags_id.test.js +++ b/test/api/v2/user/GET-user_tags_id.test.js @@ -6,18 +6,18 @@ import { describe('GET /user/tags/id', () => { let user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((usr) => { user = usr; }); }); - it('gets a user\'s tag by id', () => { + it('gets a user\'s tag by id', async () => { return expect(user.get('/user/tags/' + user.tags[0].id)) .to.eventually.eql(user.tags[0]); }); - it('fails for non-existent tags', () => { + it('fails for non-existent tags', async () => { return expect(user.get('/user/tags/not-an-id')) .to.eventually.be.rejected.and.eql({ code: 404, diff --git a/test/api/v2/user/PUT-user.test.js b/test/api/v2/user/PUT-user.test.js index ac0b8a3dd5..2055125e94 100644 --- a/test/api/v2/user/PUT-user.test.js +++ b/test/api/v2/user/PUT-user.test.js @@ -8,14 +8,14 @@ import { each } from 'lodash'; describe('PUT /user', () => { let user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((usr) => { user = usr; }); }); context('allowed operations', () => { - it('updates the user', () => { + it('updates the user', async () => { return user.put('/user', { 'profile.name' : 'Frodo', 'preferences.costume': true, @@ -40,7 +40,7 @@ describe('PUT /user', () => { }; each(protectedOperations, (data, testName) => { - it(`does not allow updating ${testName}`, () => { + it(`does not allow updating ${testName}`, async () => { let errorText = []; each(data, (value, operation) => { errorText.push(t('messageUserOperationProtected', { operation: operation })); @@ -59,7 +59,7 @@ describe('PUT /user', () => { }; each(protectedOperations, (data, testName) => { - it(`does not allow updating ${testName}`, () => { + it(`does not allow updating ${testName}`, async () => { let errorText = []; each(data, (value, operation) => { errorText.push(t('messageUserOperationProtected', { operation: operation })); diff --git a/test/api/v2/user/anonymized/GET-user_anonymized.test.js b/test/api/v2/user/anonymized/GET-user_anonymized.test.js index 82fc5b61ff..9a4a4aa0cc 100644 --- a/test/api/v2/user/anonymized/GET-user_anonymized.test.js +++ b/test/api/v2/user/anonymized/GET-user_anonymized.test.js @@ -6,7 +6,7 @@ import { each } from 'lodash'; describe('GET /user/anonymized', () => { let user; - before(() => { + before(async () => { return generateUser({ 'inbox.messages' : { 'the-message-id' : { @@ -47,24 +47,24 @@ describe('GET /user/anonymized', () => { }); }); - it('retains user id', () => { + it('retains user id', async () => { expect(user._id).to.exist; }); - it('removes credentials and financial information', () => { + it('removes credentials and financial information', async () => { expect(user.apiToken).to.not.exist; expect(user.auth.local).to.not.exist; expect(user.auth.facebook).to.not.exist; expect(user.purchased.plan).to.not.exist; }); - it('removes profile information', () => { + it('removes profile information', async () => { expect(user.profile).to.not.exist; expect(user.contributor).to.not.exist; expect(user.achievements.challenges).to.not.exist; }); - it('removes social information', () => { + it('removes social information', async () => { expect(user.newMessages).to.not.exist; expect(user.invitations).to.not.exist; expect(user.items.special.nyeReceived).to.not.exist; @@ -75,7 +75,7 @@ describe('GET /user/anonymized', () => { }); }); - it('anonymizes task info', () => { + it('anonymizes task info', async () => { each(['habits', 'todos', 'dailys', 'rewards'], (tasks) => { each(user[tasks], (task) => { expect(task.text).to.eql('task text'); @@ -88,14 +88,14 @@ describe('GET /user/anonymized', () => { }); }); - it('anonymizes tags', () => { + it('anonymizes tags', async () => { each(user.tags, (tag) => { expect(tag.name).to.eql('tag'); expect(tag.challenge).to.eql('challenge'); }); }); - it('removes webhooks', () => { + it('removes webhooks', async () => { expect(user.webhooks).to.not.exist; }); }); diff --git a/test/api/v2/user/batch-update/POST-user_batch-update.test.js b/test/api/v2/user/batch-update/POST-user_batch-update.test.js index 6c0024e526..30a85c3607 100644 --- a/test/api/v2/user/batch-update/POST-user_batch-update.test.js +++ b/test/api/v2/user/batch-update/POST-user_batch-update.test.js @@ -8,14 +8,14 @@ import { each } from 'lodash'; describe('POST /user/batch-update', () => { let user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((usr) => { user = usr; }); }); context('allowed operations', () => { - it('makes batch operations', () => { + it('makes batch operations', async () => { let task; return user.get('/user/tasks').then((tasks) => { @@ -45,7 +45,7 @@ describe('POST /user/batch-update', () => { each(protectedOperations, (operation, description) => { - it(`it sends back a 500 error for ${description} operation`, () => { + it(`it sends back a 500 error for ${description} operation`, async () => { return expect(user.post('/user/batch-update', [ { op: operation }, ])).to.eventually.be.rejected.and.eql({ @@ -57,7 +57,7 @@ describe('POST /user/batch-update', () => { }); context('unknown operations', () => { - it('sends back a 500 error', () => { + it('sends back a 500 error', async () => { return expect(user.post('/user/batch-update', [ {op: 'aNotRealOperation'}, ])).to.eventually.be.rejected.and.eql({ diff --git a/test/api/v2/user/pushDevice/POST-pushDevice.test.js b/test/api/v2/user/pushDevice/POST-pushDevice.test.js index 3a467b21a9..f75e1a541b 100644 --- a/test/api/v2/user/pushDevice/POST-pushDevice.test.js +++ b/test/api/v2/user/pushDevice/POST-pushDevice.test.js @@ -5,13 +5,13 @@ import { describe('POST /user/pushDevice', () => { let user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((_user) => { user = _user; }); }); - it('registers a device id', () => { + it('registers a device id', async () => { return user.post('/user/pushDevice', { regId: '123123', type: 'android', diff --git a/test/api/v2/user/tasks/DELETE-tasks_id.test.js b/test/api/v2/user/tasks/DELETE-tasks_id.test.js index 521f1552f5..f7e8e2347b 100644 --- a/test/api/v2/user/tasks/DELETE-tasks_id.test.js +++ b/test/api/v2/user/tasks/DELETE-tasks_id.test.js @@ -6,14 +6,14 @@ import { describe('DELETE /user/tasks/:id', () => { let user, task; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((_user) => { user = _user; task = user.todos[0]; }); }); - it('deletes a task', () => { + it('deletes a task', async () => { return expect(user.del(`/user/tasks/${task.id}`) .then((res) => { return user.get(`/user/tasks/${task.id}`); @@ -23,7 +23,7 @@ describe('DELETE /user/tasks/:id', () => { }); }); - it('returns an error if the task does not exist', () => { + it('returns an error if the task does not exist', async () => { return expect(user.del('/user/tasks/task-that-does-not-exist')) .to.eventually.be.rejected.and.eql({ code: 404, @@ -31,7 +31,7 @@ describe('DELETE /user/tasks/:id', () => { }); }); - it('does not delete another user\'s task', () => { + it('does not delete another user\'s task', async () => { return expect(generateUser().then((otherUser) => { let otherUsersTask = otherUser.todos[0]; return user.del(`/user/tasks/${otherUsersTask.id}`); diff --git a/test/api/v2/user/tasks/GET-tasks.test.js b/test/api/v2/user/tasks/GET-tasks.test.js index 8e8023d000..5ff1ff3192 100644 --- a/test/api/v2/user/tasks/GET-tasks.test.js +++ b/test/api/v2/user/tasks/GET-tasks.test.js @@ -6,7 +6,7 @@ import { describe('GET /user/tasks/', () => { let user; - beforeEach(() => { + beforeEach(async () => { return generateUser({ dailys: [ {text: 'daily', type: 'daily'}, @@ -19,7 +19,7 @@ describe('GET /user/tasks/', () => { }); }); - it('gets all tasks', () => { + it('gets all tasks', async () => { return user.get(`/user/tasks/`).then((tasks) => { expect(tasks).to.be.an('array'); expect(tasks.length).to.be.greaterThan(3); diff --git a/test/api/v2/user/tasks/GET-tasks_id.test.js b/test/api/v2/user/tasks/GET-tasks_id.test.js index 30aa9ef29f..275296cb36 100644 --- a/test/api/v2/user/tasks/GET-tasks_id.test.js +++ b/test/api/v2/user/tasks/GET-tasks_id.test.js @@ -6,14 +6,14 @@ import { describe('GET /user/tasks/:id', () => { let user, task; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((_user) => { user = _user; task = user.todos[0]; }); }); - it('gets a task', () => { + it('gets a task', async () => { return user.get(`/user/tasks/${task.id}`).then((foundTask) => { expect(foundTask.id).to.eql(task.id); expect(foundTask.text).to.eql(task.text); @@ -23,7 +23,7 @@ describe('GET /user/tasks/:id', () => { }); }); - it('returns an error if the task does not exist', () => { + it('returns an error if the task does not exist', async () => { return expect(user.get('/user/tasks/task-that-does-not-exist')) .to.eventually.be.rejected.and.eql({ code: 404, @@ -31,7 +31,7 @@ describe('GET /user/tasks/:id', () => { }); }); - it('does not get another user\'s task', () => { + it('does not get another user\'s task', async () => { return expect(generateUser().then((otherUser) => { let otherUsersTask = otherUser.todos[0]; diff --git a/test/api/v2/user/tasks/POST-tasks.test.js b/test/api/v2/user/tasks/POST-tasks.test.js index 44bc468352..3615cede5a 100644 --- a/test/api/v2/user/tasks/POST-tasks.test.js +++ b/test/api/v2/user/tasks/POST-tasks.test.js @@ -7,24 +7,24 @@ describe('POST /user/tasks', () => { let user; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((_user) => { user = _user; }); }); - it('creates a task', () => { + it('creates a task', async () => { return user.post('/user/tasks').then((task) => { expect(task.id).to.exist; }); }); - it('creates a habit by default', () => { + it('creates a habit by default', async () => { return expect(user.post('/user/tasks')) .to.eventually.have.property('type', 'habit'); }); - it('creates a task with specified values', () => { + it('creates a task with specified values', async () => { return user.post('/user/tasks', { type: 'daily', text: 'My task', @@ -38,7 +38,7 @@ describe('POST /user/tasks', () => { }); }); - it('does not create a task with an id that already exists', () => { + it('does not create a task with an id that already exists', async () => { let todo = user.todos[0]; return expect(user.post('/user/tasks', { @@ -49,7 +49,7 @@ describe('POST /user/tasks', () => { }); }); - xit('TODO: no error is thrown - throws a 500 validation error if invalid type is posted', () => { + xit('TODO: no error is thrown - throws a 500 validation error if invalid type is posted', async () => { return expect(user.post('/user/tasks', { type: 'not-valid', })).to.eventually.be.rejected.and.eql({ @@ -58,7 +58,7 @@ describe('POST /user/tasks', () => { }); }); - xit('TODO: no error is thrown - throws a 500 validation error if invalid data is posted', () => { + xit('TODO: no error is thrown - throws a 500 validation error if invalid data is posted', async () => { return expect(user.post('/user/tasks', { frequency: 'not-valid', })).to.eventually.be.rejected.and.eql({ diff --git a/test/api/v2/user/tasks/PUT-tasks_id.test.js b/test/api/v2/user/tasks/PUT-tasks_id.test.js index ad5243da13..054ed7fcd2 100644 --- a/test/api/v2/user/tasks/PUT-tasks_id.test.js +++ b/test/api/v2/user/tasks/PUT-tasks_id.test.js @@ -6,14 +6,14 @@ import { describe('PUT /user/tasks/:id', () => { let user, task; - beforeEach(() => { + beforeEach(async () => { return generateUser().then((_user) => { user = _user; task = user.todos[0]; }); }); - it('does not update the id of the task', () => { + it('does not update the id of the task', async () => { return user.put(`/user/tasks/${task.id}`, { id: 'some-thing', }).then((updatedTask) => { @@ -22,7 +22,7 @@ describe('PUT /user/tasks/:id', () => { }); }); - it('does not update the type of the task', () => { + it('does not update the type of the task', async () => { return user.put(`/user/tasks/${task.id}`, { type: 'habit', }).then((updatedTask) => { @@ -31,7 +31,7 @@ describe('PUT /user/tasks/:id', () => { }); }); - it('updates text, attribute, priority, value and notes', () => { + it('updates text, attribute, priority, value and notes', async () => { return user.put(`/user/tasks/${task.id}`, { text: 'new text', notes: 'new notes', @@ -47,7 +47,7 @@ describe('PUT /user/tasks/:id', () => { }); }); - it('returns an error if the task does not exist', () => { + it('returns an error if the task does not exist', async () => { return expect(user.put('/user/tasks/task-id-that-does-not-exist')) .to.eventually.be.rejected.and.eql({ code: 404, @@ -55,7 +55,7 @@ describe('PUT /user/tasks/:id', () => { }); }); - it('does not update another user\'s task', () => { + it('does not update another user\'s task', async () => { return expect(generateUser().then((otherUser) => { let otherUsersTask = otherUser.todos[0]; return user.put(`/user/tasks/${otherUsersTask._id}`, {