@@ -411,7 +411,7 @@ describe('PaddleIntegration', () => {
411
411
} )
412
412
} )
413
413
414
- describe ( '.getPaymentsTrail ' , ( ) => {
414
+ describe ( '.getStatusTrail ' , ( ) => {
415
415
beforeEach ( async ( ) => {
416
416
const subscriptionId = uuid ( )
417
417
const createPayload = Object . assign ( { } , subscriptionCreated , {
@@ -484,4 +484,46 @@ describe('PaddleIntegration', () => {
484
484
expect ( trail [ 2 ] . subscription_plan_id ) . to . equal ( paymentSucceded . subscription_plan_id )
485
485
} )
486
486
} )
487
+ describe ( '.getStatusTrail' , ( ) => {
488
+ beforeEach ( async ( ) => {
489
+ const subscriptionId = uuid ( )
490
+
491
+ const createPayload = Object . assign ( { } , subscriptionCreated ,
492
+ {
493
+ event_time : '2024-08-08 10:47:47' ,
494
+ subscription_id : subscriptionId , passthrough : JSON . stringify ( { ids } )
495
+ }
496
+ )
497
+ await paddleIntegration . addSubscriptionCreatedStatus ( createPayload )
498
+
499
+ const updatePayload = Object . assign ( { } , subscriptionUpdated ,
500
+ {
501
+ event_time : '2026-08-08 10:47:47' ,
502
+ subscription_id : subscriptionId , passthrough : JSON . stringify ( { ids } )
503
+ }
504
+ )
505
+ await paddleIntegration . addSubscriptionUpdatedStatus ( updatePayload )
506
+
507
+ const cancelPayload = Object . assign ( { } , subscriptionCancelled ,
508
+ {
509
+ subscription_id : subscriptionId ,
510
+ passthrough : JSON . stringify ( { ids } ) ,
511
+ cancellation_effective_date : '2028-08-08 10:47:47' ,
512
+ }
513
+ )
514
+ await paddleIntegration . addSubscriptionCancelledStatus ( cancelPayload )
515
+ } )
516
+ it ( 'returns a sorted listed of payments' , async ( ) => {
517
+ const { subscription : sub } = await storage . get ( ids )
518
+ const trail = await paddleIntegration . getStatusTrail ( sub )
519
+
520
+ expect ( trail ) . to . have . length ( 3 )
521
+ expect ( trail [ 0 ] . type ) . to . equal ( 'subscription_created' )
522
+ expect ( trail [ 0 ] . description ) . to . equal ( 'active' )
523
+ expect ( trail [ 1 ] . type ) . to . equal ( 'subscription_updated' )
524
+ expect ( trail [ 1 ] . description ) . to . equal ( 'active' )
525
+ expect ( trail [ 2 ] . type ) . to . equal ( 'subscription_cancelled' )
526
+ expect ( trail [ 2 ] . description ) . to . equal ( 'deleted' )
527
+ } )
528
+ } )
487
529
} )
0 commit comments