@@ -79,7 +79,7 @@ describe('SubscriptionsList', () => {
7979 } ) ;
8080 } ) ;
8181
82- it ( 'displays past due badge when subscription is past due' , async ( ) => {
82+ it ( 'on past due, no badge, but past due date is shown ' , async ( ) => {
8383 const { wrapper, fixtures } = await createFixtures ( f => {
8484 f . withUser ( { email_addresses : [ 'test@clerk.com' ] } ) ;
8585 } ) ;
@@ -133,17 +133,17 @@ describe('SubscriptionsList', () => {
133133 reload : jest . fn ( ) ,
134134 } ) ;
135135
136- const { getByText } = render ( < SubscriptionsList { ...props } /> , { wrapper } ) ;
136+ const { getByText, queryByText } = render ( < SubscriptionsList { ...props } /> , { wrapper } ) ;
137137
138138 await waitFor ( ( ) => {
139139 expect ( getByText ( 'Pro Plan' ) ) . toBeVisible ( ) ;
140140 // Past due subscription should show the Past due badge
141- expect ( getByText ( / ^ P a s t d u e $ / ) ) . toBeVisible ( ) ;
141+ expect ( queryByText ( / ^ P a s t d u e $ / ) ) . toBeNull ( ) ;
142142 expect ( getByText ( / P a s t d u e J a n 1 5 , 2 0 2 1 / ) ) . toBeVisible ( ) ;
143143 } ) ;
144144 } ) ;
145145
146- it ( 'displays active badge when subscription is active' , async ( ) => {
146+ it ( 'does not display active badge when subscription is active and it is a single item ' , async ( ) => {
147147 const { wrapper, fixtures } = await createFixtures ( f => {
148148 f . withUser ( { email_addresses : [ 'test@clerk.com' ] } ) ;
149149 } ) ;
@@ -197,80 +197,16 @@ describe('SubscriptionsList', () => {
197197 reload : jest . fn ( ) ,
198198 } ) ;
199199
200- const { getByText } = render ( < SubscriptionsList { ...props } /> , { wrapper } ) ;
201-
202- await waitFor ( ( ) => {
203- expect ( getByText ( 'Pro Plan' ) ) . toBeVisible ( ) ;
204- // Active subscription should show the Active badge
205- expect ( getByText ( / ^ A c t i v e $ / ) ) . toBeVisible ( ) ;
206- } ) ;
207- } ) ;
208-
209- it ( 'does not display badge when single subscription is canceled' , async ( ) => {
210- const { wrapper, fixtures } = await createFixtures ( f => {
211- f . withUser ( { email_addresses : [ 'test@clerk.com' ] } ) ;
212- } ) ;
213-
214- const canceledSubscription = {
215- id : 'sub_canceled' ,
216- plan : {
217- id : 'plan_canceled' ,
218- name : 'Pro Plan' ,
219- fee : { amount : 2000 , amountFormatted : '20.00' , currencySymbol : '$' , currency : 'USD' } ,
220- annualFee : { amount : 20000 , amountFormatted : '200.00' , currencySymbol : '$' , currency : 'USD' } ,
221- annualMonthlyFee : { amount : 1667 , amountFormatted : '16.67' , currencySymbol : '$' , currency : 'USD' } ,
222- description : 'Pro Plan Description' ,
223- isDefault : false ,
224- isRecurring : true ,
225- hasBaseFee : true ,
226- forPayerType : 'user' as CommercePayerResourceType ,
227- publiclyVisible : true ,
228- slug : 'pro-plan' ,
229- avatarUrl : '' ,
230- features : [ ] ,
231- freeTrialDays : null ,
232- freeTrialEnabled : false ,
233- pathRoot : '' ,
234- reload : jest . fn ( ) ,
235- } ,
236- createdAt : new Date ( '2021-01-01' ) ,
237- periodStart : new Date ( '2021-01-01' ) ,
238- periodEnd : new Date ( '2021-02-01' ) ,
239- canceledAt : new Date ( '2021-01-15' ) , // This subscription is canceled
240- paymentSourceId : 'src_canceled' ,
241- planPeriod : 'month' as const ,
242- status : 'active' as const ,
243- isFreeTrial : false ,
244- pastDueAt : null ,
245- cancel : jest . fn ( ) ,
246- pathRoot : '' ,
247- reload : jest . fn ( ) ,
248- } ;
249-
250- fixtures . clerk . billing . getSubscription . mockResolvedValue ( {
251- id : 'sub_top' ,
252- status : 'active' ,
253- activeAt : new Date ( '2021-01-01' ) ,
254- createdAt : new Date ( '2021-01-01' ) ,
255- nextPayment : null ,
256- pastDueAt : null ,
257- updatedAt : null ,
258- subscriptionItems : [ canceledSubscription ] ,
259- pathRoot : '' ,
260- reload : jest . fn ( ) ,
261- } ) ;
262-
263200 const { getByText, queryByText } = render ( < SubscriptionsList { ...props } /> , { wrapper } ) ;
264201
265202 await waitFor ( ( ) => {
266203 expect ( getByText ( 'Pro Plan' ) ) . toBeVisible ( ) ;
267- // Single canceled subscription should not show badge (canceledAt !== null means no badge)
204+ // Active subscription should show the Active badge
268205 expect ( queryByText ( / ^ A c t i v e $ / ) ) . toBeNull ( ) ;
269- expect ( queryByText ( / ^ F r e e t r i a l $ / ) ) . toBeNull ( ) ;
270206 } ) ;
271207 } ) ;
272208
273- it ( 'renders upcomming badge when subscription is upcoming ' , async ( ) => {
209+ it ( 'renders upcomming badge when current subscription is canceled but active ' , async ( ) => {
274210 const { wrapper, fixtures } = await createFixtures ( f => {
275211 f . withUser ( { email_addresses : [ 'test@clerk.com' ] } ) ;
276212 } ) ;
0 commit comments