declastruct-stripe-sdk
Version:
declarative control of stripe constructs, via declastruct
40 lines • 2.18 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const test_fns_1 = require("test-fns");
const uuid_fns_1 = require("uuid-fns");
const getStripeCredentials_1 = require("../../__test_assets__/getStripeCredentials");
const getStripe_1 = require("../auth/getStripe");
const getCustomer_1 = require("./getCustomer");
const setCustomer_1 = require("./setCustomer");
describe('getCustomer', () => {
(0, test_fns_1.given)('a by.primary', () => {
(0, test_fns_1.when)('the customer does not exist', () => {
const stripeCustomerId = (0, uuid_fns_1.getUuid)();
(0, test_fns_1.then)('we should get null', async () => {
const customer = await (0, getCustomer_1.getCustomer)({ by: { primary: { id: stripeCustomerId } } }, { stripe: await (0, getStripe_1.getStripe)((0, getStripeCredentials_1.getStripeCredentials)()), log: console });
expect(customer).toEqual(null);
});
});
(0, test_fns_1.when)('the customer does exist', () => {
let customerFound;
beforeAll(async () => {
customerFound = await (0, setCustomer_1.setCustomer)({
finsert: {
email: 'svc-protools@ahbode.dev',
name: 'svc-protools.test',
description: 'test',
metadata: null,
phone: null,
},
}, { stripe: await (0, getStripe_1.getStripe)((0, getStripeCredentials_1.getStripeCredentials)()), log: console });
});
(0, test_fns_1.when)('we attempt to get the customer', () => {
(0, test_fns_1.then)('we should get null', async () => {
const customer = await (0, getCustomer_1.getCustomer)({ by: { primary: { id: customerFound.id } } }, { stripe: await (0, getStripe_1.getStripe)((0, getStripeCredentials_1.getStripeCredentials)()), log: console });
expect(customer?.id).toEqual(customerFound.id);
});
});
});
});
});
//# sourceMappingURL=getCustomer.integration.test.js.map