Payment refactor (#10325)

* Rarranged payment index functions

* Moved gem function

* Increased buy gems test coverage

* Reduced length of functions. Reduced cognitive complexity
This commit is contained in:
Keith Holliday
2018-05-06 15:12:00 -05:00
committed by GitHub
parent 5231cb03a8
commit 6af50c9f2f
6 changed files with 688 additions and 596 deletions
@@ -632,6 +632,15 @@ describe('payments/index', () => {
expect(user.sendMessage).to.be.calledWith(recipient, { receiverMsg: msg, senderMsg: msg });
});
it('sends a message from purchaser to recipient wtih custom message', async () => {
data.gift.message = 'giftmessage';
await api.buyGems(data);
const msg = `\`Hello recipient, sender has sent you 4 gems!\` ${data.gift.message}`;
expect(user.sendMessage).to.be.calledWith(recipient, { receiverMsg: msg, senderMsg: msg });
});
it('sends a push notification if user did not gift to self', async () => {
await api.buyGems(data);
expect(notifications.sendNotification).to.be.calledOnce;