mirror of
https://github.com/rgrgogu/new_starr.git
synced 2026-09-27 00:12:54 +08:00
purchase / checkout flow
Signed-off-by: Kenneth Obsequio <k80308392@gmail.com>
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
jest.mock('../../models/tiers/tier_categories.mdl', () => ({}));
|
||||
jest.mock('../../models/tiers/tier_plans.mdl', () => ({ findOne: jest.fn() }));
|
||||
jest.mock('../../models/tiers/user_tiers.mdl', () => ({ findOne: jest.fn(), create: jest.fn() }));
|
||||
jest.mock('../../models/tiers/payments.mdl', () => ({ findOne: jest.fn() }));
|
||||
jest.mock('../../models/tiers/payments.mdl', () => ({ findAll: jest.fn() }));
|
||||
jest.mock('../../models/system_badges/system_badges.mdl', () => ({}));
|
||||
jest.mock('../../models/assets/assets.mdl', () => ({}));
|
||||
jest.mock('../../models/notifications/user_notification.mdl', () => ({ create: jest.fn() }));
|
||||
@@ -57,7 +57,7 @@ describe('captureOrder() — declined/incomplete captures must not grant access'
|
||||
|
||||
test('capture.status "DECLINED" marks the payment failed and creates no tier', async () => {
|
||||
const payment = makePayment();
|
||||
mdl_Payments.findOne.mockResolvedValue(payment);
|
||||
mdl_Payments.findAll.mockResolvedValue([payment]);
|
||||
paymentSvc.captureOrder.mockResolvedValue({
|
||||
status: 'COMPLETED', // outer order status can still say COMPLETED
|
||||
purchase_units: [{ payments: { captures: [{ id: 'CAP-1', status: 'DECLINED' }] } }],
|
||||
@@ -77,7 +77,7 @@ describe('captureOrder() — declined/incomplete captures must not grant access'
|
||||
|
||||
test('capture.status "PENDING" (e.g. eCheck review) also withholds access', async () => {
|
||||
const payment = makePayment();
|
||||
mdl_Payments.findOne.mockResolvedValue(payment);
|
||||
mdl_Payments.findAll.mockResolvedValue([payment]);
|
||||
paymentSvc.captureOrder.mockResolvedValue({
|
||||
status: 'COMPLETED',
|
||||
purchase_units: [{ payments: { captures: [{ id: 'CAP-2', status: 'PENDING' }] } }],
|
||||
@@ -97,7 +97,7 @@ describe('captureOrder() — declined/incomplete captures must not grant access'
|
||||
|
||||
test('capture.status "COMPLETED" still grants the tier (control case)', async () => {
|
||||
const payment = makePayment();
|
||||
mdl_Payments.findOne.mockResolvedValue(payment);
|
||||
mdl_Payments.findAll.mockResolvedValue([payment]);
|
||||
mdl_UserTiers.findOne.mockResolvedValue(null); // no existing active tier
|
||||
mdl_UserTiers.create.mockResolvedValue({ tier_id: 99, tier: 'premium', expires_at: new Date() });
|
||||
paymentSvc.captureOrder.mockResolvedValue({
|
||||
|
||||
Reference in New Issue
Block a user