diff --git a/test/api/v3/integration/groups/POST-groups_invite.test.js b/test/api/v3/integration/groups/POST-groups_invite.test.js index d3f2b78c27..0f59bd5966 100644 --- a/test/api/v3/integration/groups/POST-groups_invite.test.js +++ b/test/api/v3/integration/groups/POST-groups_invite.test.js @@ -3,7 +3,6 @@ import { translate as t, } from '../../../../helpers/api-v3-integration.helper'; import { v4 as generateUUID } from 'uuid'; -import * as email from '../../../../../website/src/libs/api-v3/email'; const INVITES_LIMIT = 100; @@ -20,10 +19,6 @@ describe('Post /groups/:groupId/invite', () => { }); }); - afterEach(() => { - if (email.sendTxn.restore) email.sendTxn.restore(); - }); - describe('user id invites', () => { it('returns an error when invited user is not found', async () => { let fakeID = generateUUID(); @@ -75,10 +70,9 @@ describe('Post /groups/:groupId/invite', () => { }); }); - it.only('invites a user to a group by uuid', async () => { + it('invites a user to a group by uuid', async () => { let userToInvite = await generateUser(); - sandbox.stub(email, 'sendTxn'); await expect(inviter.post(`/groups/${group._id}/invite`, { uuids: [userToInvite._id], })).to.eventually.deep.equal([{ @@ -87,12 +81,6 @@ describe('Post /groups/:groupId/invite', () => { inviter: inviter._id, }]); - expect(email.sendTxn).to.be.calledOnce; - expect(email.sendTxn[0][0]._id).to.equal(userToInvite._id); - expect(email.sendTxn[0][1]).to.equal('invited-guild'); - expect(email.sendTxn[0][2]).to.have.all.keys(['GUILD_NAME', 'GUILD_URL', 'INVITER']); - expect(email.sendTxn[0][2].INVITER).to.equal(inviter.profile.name); - await expect(userToInvite.get('/user')) .to.eventually.have.deep.property('invitations.guilds[0].id', group._id); }); @@ -115,7 +103,6 @@ describe('Post /groups/:groupId/invite', () => { inviter: inviter._id, }, ]); - expect(email.sendTxn).to.be.calledTwice; 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); @@ -190,21 +177,12 @@ describe('Post /groups/:groupId/invite', () => { emails: [testInvite], inviter: 'inviter name', })).to.exist; - - expect(email.sendTxn).to.be.calledOnce; - expect(email.sendTxn[0][0]).to.eql(testInvite); - expect(email.sendTxn[0][1]).to.equal('invite-friend-guild'); - expect(email.sendTxn[0][2]).to.have.all.keys(['GUILD_NAME', 'LINK', 'INVITER']); - expect(email.sendTxn[0][2].INVITER).to.equal('inviter name'); }); it('invites multiple users to a group by email', async () => { await expect(inviter.post(`/groups/${group._id}/invite`, { emails: [testInvite, {name: 'test2', email: 'test2@habitica.com'}], })).to.exist; - - expect(email.sendTxn).to.be.calledTwice; - expect(email.sendTxn[0][2].INVITER).to.equal(inviter.profile.name); }); }); @@ -249,9 +227,8 @@ describe('Post /groups/:groupId/invite', () => { }); let invitedUser = await newUser.get('/user'); - expect(invite).to.exist; expect(invitedUser.invitations.guilds[0].id).to.equal(group._id); - expect(email.sendTxn).to.be.calledTwice; + expect(invite).to.exist; }); }); @@ -346,8 +323,6 @@ describe('Post /groups/:groupId/invite', () => { uuids: [userToInvite._id], }); expect((await userToInvite.get('/user')).invitations.party.id).to.equal(party._id); - - expect(email.sendTxn).to.be.calledOnce; }); }); });