Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('Canceled', async () => {
const braintreeProvider = module.get(BraintreeProvider);
const braintreeWebhookProvider = module.get(BraintreeWebhookProvider);
const webhookNotification = await braintreeProvider.parseWebhook(
gateway.webhookTesting.sampleNotification(
braintree.WebhookNotification.Kind.SubscriptionCanceled,
),
);
braintreeWebhookProvider.handle(webhookNotification);
expect(TestProvider.called).toBe('canceled');
});
it('/braintree/webhook (POST) Canceled', async () => {
const webhook = gateway.webhookTesting.sampleNotification(
braintree.WebhookNotification.Kind.SubscriptionCanceled,
);
return await request(app.getHttpServer())
.post('/braintree/webhook')
.set('Content-Type', 'application/json')
.send(webhook)
.expect(201);
});
it('TrialEnded', async () => {
const braintreeProvider = module.get(BraintreeProvider);
const braintreeWebhookProvider = module.get(BraintreeWebhookProvider);
const webhookNotification = await braintreeProvider.parseWebhook(
gateway.webhookTesting.sampleNotification(
braintree.WebhookNotification.Kind.SubscriptionTrialEnded,
),
);
braintreeWebhookProvider.handle(webhookNotification);
expect(TestProvider.called).toBe('trialEnded');
});
const gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: 'merchantId',
publicKey: 'publicKey',
privateKey: 'privateKey',
});
const braintreeProvider = module.get(BraintreeProvider);
const webhookProvider = module.get(
BraintreeWebhookProvider,
);
const webhookNotification = await braintreeProvider.parseWebhook(
gateway.webhookTesting.sampleNotification(
braintree.WebhookNotification.Kind.SubscriptionCanceled,
),
);
webhookProvider.handle(webhookNotification);
expect(UselessProvider.called).toBeTruthy();
});
const gateway = braintree.connect({
environment: braintree.Environment.Sandbox,
merchantId: 'merchantId',
publicKey: 'publicKey',
privateKey: 'privateKey',
});
const braintreeProvider = module.get(BraintreeProvider);
const webhookProvider = module.get(
BraintreeWebhookProvider,
);
const webhookNotification = await braintreeProvider.parseWebhook(
gateway.webhookTesting.sampleNotification(
braintree.WebhookNotification.Kind.SubscriptionCanceled,
),
);
webhookProvider.handle(webhookNotification);
expect(SubscriptionProvider.called).toBeTruthy();
});