Skip to content

Commit f894f20

Browse files
fix(test): assert optional updateSubscription through IPaymentProvider
tsc --noEmit (CI Typecheck) rejected accessing the optional updateSubscription member on the concrete ManualPaymentProvider / PayPalPaymentProvider classes (which omit it). Cast to IPaymentProvider so the "absent on non-native providers" assertion type-checks. vitest transpiles without full type-checking, so this only surfaced in CI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LVTsGCEjPyjwtjJs6qSmhR
1 parent 452ecaf commit f894f20

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

tests/unit/plan-change-provider.test.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { StripePaymentProvider } from '@/lib/payments/stripe-provider'
33
import { LemonSqueezyProvider } from '@/lib/payments/lemonsqueezy-provider'
44
import { ManualPaymentProvider } from '@/lib/payments/manual-provider'
55
import { PayPalPaymentProvider } from '@/lib/payments/paypal-provider'
6-
import { PROVIDER_CAPABILITIES } from '@/lib/payments/types'
6+
import { PROVIDER_CAPABILITIES, type IPaymentProvider } from '@/lib/payments/types'
77

88
/**
99
* Pins the native plan-change contract (#463): a provider that advertises
@@ -157,7 +157,9 @@ describe('supportsPlanChange capability', () => {
157157
it('exposes updateSubscription only on native-swap providers', () => {
158158
expect(typeof new StripePaymentProvider('sk_test_x').updateSubscription).toBe('function')
159159
expect(typeof new LemonSqueezyProvider('k', 's', 'w').updateSubscription).toBe('function')
160-
expect(new ManualPaymentProvider().updateSubscription).toBeUndefined()
161-
expect(new PayPalPaymentProvider('id', 'secret').updateSubscription).toBeUndefined()
160+
// updateSubscription is an OPTIONAL IPaymentProvider member these classes
161+
// omit — assert through the interface type so tsc is happy.
162+
expect((new ManualPaymentProvider() as IPaymentProvider).updateSubscription).toBeUndefined()
163+
expect((new PayPalPaymentProvider('id', 'secret') as IPaymentProvider).updateSubscription).toBeUndefined()
162164
})
163165
})

0 commit comments

Comments
 (0)