@@ -90,20 +90,33 @@ describe( 'siteScanReducer', () => {
9090 * ACTION_SCANNABLE_URLS_RECEIVE
9191 */
9292 it ( 'returns correct state for ACTION_SCANNABLE_URLS_RECEIVE' , ( ) => {
93- expect ( siteScanReducer ( { } , {
93+ expect ( siteScanReducer ( { scanOnce : false , scansCount : 0 } , {
9494 type : ACTION_SCANNABLE_URLS_RECEIVE ,
9595 scannableUrls : [ ] ,
9696 } ) ) . toStrictEqual ( {
9797 status : STATUS_COMPLETED ,
98- scannableUrls : [ ] ,
98+ scanOnce : false ,
99+ scansCount : 0 ,
99100 } ) ;
100101
101- expect ( siteScanReducer ( { } , {
102+ expect ( siteScanReducer ( { scanOnce : false , scansCount : 2 } , {
102103 type : ACTION_SCANNABLE_URLS_RECEIVE ,
103104 scannableUrls : [ 'foo' , 'bar' ] ,
104105 } ) ) . toStrictEqual ( {
105106 status : STATUS_READY ,
106107 scannableUrls : [ 'foo' , 'bar' ] ,
108+ scanOnce : false ,
109+ scansCount : 2 ,
110+ } ) ;
111+
112+ expect ( siteScanReducer ( { scanOnce : true , scansCount : 1 } , {
113+ type : ACTION_SCANNABLE_URLS_RECEIVE ,
114+ scannableUrls : [ 'foo' , 'bar' ] ,
115+ } ) ) . toStrictEqual ( {
116+ status : STATUS_COMPLETED ,
117+ scannableUrls : [ 'foo' , 'bar' ] ,
118+ scanOnce : true ,
119+ scansCount : 1 ,
107120 } ) ;
108121 } ) ;
109122
@@ -129,18 +142,45 @@ describe( 'siteScanReducer', () => {
129142 ] ) ( 'returns correct state for ACTION_SCAN_INITIALIZE when initial status is %s' , ( status ) => {
130143 expect ( siteScanReducer ( {
131144 status,
145+ scanOnce : false ,
146+ scansCount : 0 ,
132147 scannableUrls : [ 'foo' , 'bar' ] ,
133148 urlIndexesPendingScan : [ ] ,
134149 } , {
135150 type : ACTION_SCAN_INITIALIZE ,
136151 } ) ) . toStrictEqual ( {
137152 status : STATUS_IDLE ,
138153 currentlyScannedUrlIndexes : [ ] ,
154+ scanOnce : false ,
155+ scansCount : 1 ,
139156 scannableUrls : [ 'foo' , 'bar' ] ,
140157 urlIndexesPendingScan : [ 0 , 1 ] ,
141158 } ) ;
142159 } ) ;
143160
161+ it . each ( [
162+ STATUS_CANCELLED ,
163+ STATUS_COMPLETED ,
164+ STATUS_FAILED ,
165+ STATUS_READY ,
166+ ] ) ( 'returns correct state for ACTION_SCAN_INITIALIZE when initial status is %s and scan should be done just once' , ( status ) => {
167+ expect ( siteScanReducer ( {
168+ status,
169+ scanOnce : true ,
170+ scansCount : 1 ,
171+ scannableUrls : [ 'foo' , 'bar' ] ,
172+ urlIndexesPendingScan : [ ] ,
173+ } , {
174+ type : ACTION_SCAN_INITIALIZE ,
175+ } ) ) . toStrictEqual ( {
176+ status : STATUS_COMPLETED ,
177+ scanOnce : true ,
178+ scansCount : 1 ,
179+ scannableUrls : [ 'foo' , 'bar' ] ,
180+ urlIndexesPendingScan : [ ] ,
181+ } ) ;
182+ } ) ;
183+
144184 /**
145185 * ACTION_SCAN_URL
146186 */
0 commit comments