continuation of PR #8161 Display error notification when attempting to purchase invalid amount of gems - fixes #8145 (#8688)

* Translation string for error notification

* Use function instead of a link for paypal

* Inject notification service, function to check the amount of gems to purchase, function to handle payments with paypal

* Throw error if amount of gems is zero or negative

* Add condition to raise error if amount is negative

* Added gem errors for gifts 0 or less

* Fixed linting and broken test

* Fixed test syntax

* Added back needed strings

* Fixed group locales
This commit is contained in:
Keith Holliday
2017-07-06 14:43:43 -06:00
committed by Sabe Jones
parent 48bbc22fb4
commit e901850a6f
9 changed files with 101 additions and 4 deletions

View File

@@ -113,6 +113,25 @@ describe('Amazon Payments', () => {
expectAmazonStubs();
});
it('should error if gem amount is too low', async () => {
let receivingUser = new User();
receivingUser.save();
let gift = {
type: 'gems',
gems: {
amount: 0,
uuid: receivingUser._id,
},
};
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',
});
});
it('should gift gems', async () => {
let receivingUser = new User();
receivingUser.save();

View File

@@ -68,6 +68,25 @@ describe('Paypal Payments', () => {
expect(link).to.eql(approvalHerf);
});
it('should error if gem amount is too low', async () => {
let receivingUser = new User();
receivingUser.save();
let gift = {
type: 'gems',
gems: {
amount: 0,
uuid: receivingUser._id,
},
};
await expect(paypalPayments.checkout({gift}))
.to.eventually.be.rejected.and.to.eql({
httpCode: 400,
message: 'Amount must be at least 1.',
name: 'BadRequest',
});
});
it('creates a link for gifting gems', async () => {
let receivingUser = new User();
let gift = {

View File

@@ -48,7 +48,36 @@ describe('Stripe Payments', () => {
payments.createSubscription.restore();
});
it('should error if gem amount is too low', async () => {
let receivingUser = new User();
receivingUser.save();
gift = {
type: 'gems',
gems: {
amount: 0,
uuid: receivingUser._id,
},
};
await expect(stripePayments.checkout({
token,
user,
gift,
groupId,
email,
headers,
coupon,
}, stripe))
.to.eventually.be.rejected.and.to.eql({
httpCode: 400,
message: 'Amount must be at least 1.',
name: 'BadRequest',
});
});
it('should purchase gems', async () => {
gift = undefined;
await stripePayments.checkout({
token,
user,