@@ -235,24 +235,16 @@ describe('preBuild()', () => {
235
235
test ( 'restores cache with right paths' , async ( ) => {
236
236
await useFixture ( 'dist_dir_next_config' )
237
237
238
- let distPath
239
- const utils_ = {
240
- ...utils ,
241
- cache : {
242
- restore : ( x ) => ( distPath = x ) ,
243
- } ,
244
- }
245
- const spy = jest . spyOn ( utils_ . cache , 'restore' )
238
+ const restore = jest . fn ( )
246
239
247
240
await plugin . onPreBuild ( {
248
241
netlifyConfig,
249
242
packageJson : DUMMY_PACKAGE_JSON ,
250
- utils : utils_ ,
243
+ utils : { ... utils , cache : { restore } } ,
251
244
constants : { FUNCTIONS_SRC : 'out_functions' } ,
252
245
} )
253
246
254
- expect ( spy ) . toHaveBeenCalled ( )
255
- expect ( path . normalize ( distPath ) ) . toBe ( path . normalize ( 'build/cache' ) )
247
+ expect ( restore ) . toHaveBeenCalledWith ( path . resolve ( 'build/cache' ) )
256
248
} )
257
249
} )
258
250
@@ -316,29 +308,18 @@ describe('onPostBuild', () => {
316
308
test ( 'saves cache with right paths' , async ( ) => {
317
309
await useFixture ( 'dist_dir_next_config' )
318
310
319
- let distPath
320
- let manifestPath
321
- const utils_ = {
322
- ...utils ,
323
- cache : {
324
- save : ( x , y ) => {
325
- distPath = x
326
- manifestPath = y
327
- } ,
328
- } ,
329
- }
330
- const spy = jest . spyOn ( utils_ . cache , 'save' )
311
+ const save = jest . fn ( )
331
312
332
313
await plugin . onPostBuild ( {
333
314
netlifyConfig,
334
315
packageJson : DUMMY_PACKAGE_JSON ,
335
- utils : utils_ ,
316
+ utils : { ... utils , cache : { save } } ,
336
317
constants : { FUNCTIONS_SRC : 'out_functions' } ,
337
318
} )
338
319
339
- expect ( spy ) . toHaveBeenCalled ( )
340
- expect ( path . normalize ( distPath ) ) . toBe ( path . normalize ( 'build/cache' ) )
341
- expect ( path . normalize ( manifestPath . digests [ 0 ] ) ) . toBe ( path . normalize ( 'build/build-manifest.json' ) )
320
+ expect ( save ) . toHaveBeenCalledWith ( path . resolve ( 'build/cache' ) , {
321
+ digests : [ path . resolve ( 'build/build-manifest.json' ) ] ,
322
+ } )
342
323
} )
343
324
} )
344
325
0 commit comments