11import createRecurringOrdersSync , {
22 actionGroups ,
33} from '../src/recurring-orders'
4- import { baseActionsList } from '../src/recurring-orders-actions'
4+ import {
5+ baseActionsList ,
6+ referenceActionsList ,
7+ } from '../src/recurring-orders-actions'
58
69describe ( 'Exports' , ( ) => {
710 test ( 'action group list' , ( ) => {
8- expect ( actionGroups ) . toEqual ( [ 'base' , 'custom' ] )
11+ expect ( actionGroups ) . toEqual ( [ 'base' , 'references' , ' custom'] )
912 } )
1013
11- describe ( 'action list' , ( ) => {
14+ describe ( 'base action list' , ( ) => {
1215 test ( 'should contain `setRecurringOrderState` action' , ( ) => {
1316 expect ( baseActionsList ) . toEqual (
1417 expect . arrayContaining ( [
@@ -28,11 +31,42 @@ describe('Exports', () => {
2831 expect . arrayContaining ( [ { action : 'transitionState' , key : 'state' } ] )
2932 )
3033 } )
34+
35+ test ( 'should contain `setOrderSkipConfiguration` action' , ( ) => {
36+ expect ( baseActionsList ) . toEqual (
37+ expect . arrayContaining ( [
38+ { action : 'setOrderSkipConfiguration' , key : 'skipConfiguration' } ,
39+ ] )
40+ )
41+ } )
42+
43+ test ( 'should contain `setStartsAt` action' , ( ) => {
44+ expect ( baseActionsList ) . toEqual (
45+ expect . arrayContaining ( [ { action : 'setStartsAt' , key : 'startsAt' } ] )
46+ )
47+ } )
48+
49+ test ( 'should contain `setExpiresAt` action' , ( ) => {
50+ expect ( baseActionsList ) . toEqual (
51+ expect . arrayContaining ( [ { action : 'setExpiresAt' , key : 'expiresAt' } ] )
52+ )
53+ } )
54+ } )
55+
56+ describe ( 'reference action list' , ( ) => {
57+ test ( 'should contain `recurrencePolicy` action' , ( ) => {
58+ expect ( referenceActionsList ) . toEqual (
59+ expect . arrayContaining ( [
60+ { action : 'setSchedule' , key : 'recurrencePolicy' } ,
61+ ] )
62+ )
63+ } )
3164 } )
3265} )
3366
3467describe ( 'Actions' , ( ) => {
3568 let recurringOrdersSync
69+
3670 beforeEach ( ( ) => {
3771 recurringOrdersSync = createRecurringOrdersSync ( )
3872 } )
@@ -86,6 +120,50 @@ describe('Actions', () => {
86120 expect ( actual ) . toEqual ( expected )
87121 } )
88122
123+ test ( 'should build `setOrderSkipConfiguration` action' , ( ) => {
124+ const before = {
125+ skipConfiguration : { type : 'counter' , totalToSkip : 2 , skipped : 1 } ,
126+ }
127+ const now = {
128+ skipConfiguration : { type : 'counter' , totalToSkip : 5 } ,
129+ }
130+
131+ const expected = [
132+ {
133+ action : 'setOrderSkipConfiguration' ,
134+ ...now ,
135+ } ,
136+ ]
137+ const actual = recurringOrdersSync . buildActions ( now , before )
138+ expect ( actual ) . toEqual ( expected )
139+ } )
140+
141+ test ( 'should build `setStartsAt` action' , ( ) => {
142+ const before = { startsAt : '2025-10-01T00:00:00.000Z' }
143+ const now = { startsAt : '2026-01-10T00:00:00.000Z' }
144+ const actual = recurringOrdersSync . buildActions ( now , before )
145+ const expected = [
146+ {
147+ action : 'setStartsAt' ,
148+ ...now ,
149+ } ,
150+ ]
151+ expect ( actual ) . toEqual ( expected )
152+ } )
153+
154+ test ( 'should build `setExpiresAt` action' , ( ) => {
155+ const before = { expiresAt : '2025-10-01T00:00:00.000Z' }
156+ const now = { expiresAt : '2026-01-10T00:00:00.000Z' }
157+ const actual = recurringOrdersSync . buildActions ( now , before )
158+ const expected = [
159+ {
160+ action : 'setExpiresAt' ,
161+ ...now ,
162+ } ,
163+ ]
164+ expect ( actual ) . toEqual ( expected )
165+ } )
166+
89167 test ( 'should build `setCustomType` action' , ( ) => {
90168 const before = {
91169 custom : {
@@ -147,4 +225,28 @@ describe('Actions', () => {
147225 ]
148226 expect ( actual ) . toEqual ( expected )
149227 } )
228+
229+ test ( 'should build `setSchedule` action' , ( ) => {
230+ const before = {
231+ recurrencePolicy : {
232+ typeId : 'recurrence-policy' ,
233+ id : '999-9999-9999' ,
234+ } ,
235+ }
236+ const now = {
237+ recurrencePolicy : {
238+ typeId : 'recurrence-policy' ,
239+ id : '1212-1212-1212' ,
240+ } ,
241+ }
242+
243+ const actual = recurringOrdersSync . buildActions ( now , before )
244+ const expected = [
245+ {
246+ action : 'setSchedule' ,
247+ ...now ,
248+ } ,
249+ ]
250+ expect ( actual ) . toEqual ( expected )
251+ } )
150252} )
0 commit comments