0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-20 22:42:53 -05:00

Fixed Stripe customer model tests

no-issue

These tests were skipped out due to adding with the subscriptions
relation not working. However this functionality is redundant, as it is
not used anywhere. The tests have been updated to test that we can read
the subscriptions relation correctly.
This commit is contained in:
Fabien O'Carroll 2021-05-24 10:41:44 +01:00
parent e106a1b137
commit 2b5e22524b

View file

@ -15,8 +15,7 @@ describe('MemberStripeCustomer Model', function run() {
afterEach(testUtils.teardownDb);
describe('subscriptions', function () {
// For some reason the initial .add of MemberStripeCustomer is **not** adding a StripeCustomerSubscription :(
it.skip('Is correctly mapped to the stripe subscriptions', async function () {
it('Is correctly mapped to the stripe subscriptions', async function () {
const context = testUtils.context.admin;
const member = await Member.add({
@ -46,31 +45,12 @@ describe('MemberStripeCustomer Model', function run() {
await MemberStripeCustomer.add({
member_id: member.get('id'),
customer_id: 'fake_customer_id',
subscriptions: [{
subscription_id: 'fake_subscription_id1',
plan_id: 'fake_plan_id',
stripe_price_id: 'fake_plan_id',
plan_amount: 1337,
plan_nickname: 'e-LEET',
plan_interval: 'year',
plan_currency: 'btc',
status: 'active',
start_date: new Date(),
current_period_end: new Date(),
cancel_at_period_end: false
}]
customer_id: 'fake_customer_id'
}, context);
const subscription1 = await StripeCustomerSubscription.findOne({
subscription_id: 'fake_subscription_id1'
}, context);
should.exist(subscription1, 'StripeCustomerSubscription should have been created');
await StripeCustomerSubscription.add({
customer_id: 'fake_customer_id',
subscription_id: 'fake_subscription_id2',
subscription_id: 'fake_subscription_id',
plan_id: 'fake_plan_id',
stripe_price_id: 'fake_plan_id',
plan_amount: 1337,
@ -93,10 +73,9 @@ describe('MemberStripeCustomer Model', function run() {
const subscriptions = customer.related('subscriptions');
should.equal(subscriptions.length, 2, 'Should be two subscriptions');
should.equal(subscriptions.length, 1, 'Should be two subscriptions');
should.equal(subscriptions.models[0].get('subscription_id'), 'fake_subscription_id1');
should.equal(subscriptions.models[1].get('subscription_id'), 'fake_subscription_id2');
should.equal(subscriptions.models[0].get('subscription_id'), 'fake_subscription_id');
});
});