@@ -9,7 +9,7 @@ import getNode from 'get-node'
9
9
import moize from 'moize'
10
10
import { pathExists } from 'path-exists'
11
11
import semver from 'semver'
12
- import sinon from 'sinon '
12
+ import { spy , spyOn } from 'tinyspy '
13
13
import { tmpName } from 'tmp-promise'
14
14
15
15
import { zipItAndShipIt } from '../../lib/plugins_core/functions/index.js'
@@ -425,8 +425,8 @@ test('Print warning when headers file is missing from publish directory', async
425
425
} )
426
426
427
427
test . serial ( 'Passes the right properties to zip-it-and-ship-it' , async ( t ) => {
428
- const mockZipFunctions = sinon . stub ( ) . resolves ( )
429
- const stub = sinon . stub ( zipItAndShipIt , 'zipFunctions' ) . get ( ( ) => mockZipFunctions )
428
+ const mockZipFunctions = spy ( ( ) => Promise . resolve ( ) )
429
+ const stub = spyOn ( zipItAndShipIt , 'zipFunctions' , mockZipFunctions )
430
430
const fixtureDir = join ( FIXTURES_DIR , 'core' )
431
431
432
432
await new Fixture ( './fixtures/core' ) . runWithBuild ( )
@@ -439,7 +439,7 @@ test.serial('Passes the right properties to zip-it-and-ship-it', async (t) => {
439
439
440
440
t . is ( mockZipFunctions . callCount , 2 )
441
441
442
- const params1 = mockZipFunctions . firstCall . args [ 2 ]
442
+ const params1 = mockZipFunctions . calls [ 0 ] [ 2 ]
443
443
444
444
t . is ( params1 . basePath , fixtureDir )
445
445
t . true ( params1 . config [ '*' ] . zipGo )
@@ -453,15 +453,15 @@ test.serial('Passes the right properties to zip-it-and-ship-it', async (t) => {
453
453
t . is ( params1 . config [ '*' ] . nodeVersion , undefined )
454
454
}
455
455
456
- const params2 = mockZipFunctions . secondCall . args [ 2 ]
456
+ const params2 = mockZipFunctions . calls [ 1 ] [ 2 ]
457
457
458
458
t . is ( params2 . config [ '*' ] . nodeVersion , 'nodejs00.x' )
459
459
t . is ( params2 . config [ '*' ] . zipGo , undefined )
460
460
} )
461
461
462
462
test . serial ( 'Passes functions generated by build plugins to zip-it-and-ship-it' , async ( t ) => {
463
- const mockZipFunctions = sinon . stub ( ) . resolves ( [ ] )
464
- const stub = sinon . stub ( zipItAndShipIt , 'zipFunctions' ) . get ( ( ) => mockZipFunctions )
463
+ const mockZipFunctions = spy ( ( ) => Promise . resolve ( [ ] ) )
464
+ const stub = spyOn ( zipItAndShipIt , 'zipFunctions' , mockZipFunctions )
465
465
const fixtureName = 'functions_generated_from_steps'
466
466
const fixtureDir = join ( FIXTURES_DIR , fixtureName )
467
467
@@ -474,7 +474,7 @@ test.serial('Passes functions generated by build plugins to zip-it-and-ship-it',
474
474
t . true ( success )
475
475
t . is ( mockZipFunctions . callCount , 1 )
476
476
477
- const { generated, user } = mockZipFunctions . firstCall . args [ 0 ]
477
+ const { generated, user } = mockZipFunctions . calls [ 0 ] [ 0 ]
478
478
479
479
t . is ( generated . directories . length , 2 )
480
480
t . true ( generated . directories . includes ( resolve ( fixtureDir , '.netlify/functions-internal' ) ) )
@@ -501,8 +501,8 @@ test.serial('Passes functions generated by build plugins to zip-it-and-ship-it',
501
501
} )
502
502
503
503
test . serial ( 'Passes the right feature flags to zip-it-and-ship-it' , async ( t ) => {
504
- const mockZipFunctions = sinon . stub ( ) . resolves ( )
505
- const stub = sinon . stub ( zipItAndShipIt , 'zipFunctions' ) . get ( ( ) => mockZipFunctions )
504
+ const mockZipFunctions = spy ( ( ) => Promise . resolve ( ) )
505
+ const stub = spyOn ( zipItAndShipIt , 'zipFunctions' , mockZipFunctions )
506
506
507
507
await new Fixture ( './fixtures/schedule' ) . runWithBuild ( )
508
508
await new Fixture ( './fixtures/schedule' ) . withFlags ( { featureFlags : { buildbot_zisi_trace_nft : true } } ) . runWithBuild ( )
@@ -517,16 +517,16 @@ test.serial('Passes the right feature flags to zip-it-and-ship-it', async (t) =>
517
517
518
518
t . is ( mockZipFunctions . callCount , 4 )
519
519
520
- t . false ( mockZipFunctions . getCall ( 0 ) . args [ 2 ] . featureFlags . traceWithNft )
521
- t . false ( mockZipFunctions . getCall ( 0 ) . args [ 2 ] . featureFlags . parseWithEsbuild )
522
- t . is ( mockZipFunctions . getCall ( 0 ) . args [ 2 ] . config . test . schedule , '@daily' )
523
- t . is ( mockZipFunctions . getCall ( 0 ) . args [ 2 ] . featureFlags . this_is_a_mock_flag , undefined )
524
- t . is ( mockZipFunctions . getCall ( 0 ) . args [ 2 ] . featureFlags . and_another_one , undefined )
520
+ t . false ( mockZipFunctions . calls [ 0 ] [ 2 ] . featureFlags . traceWithNft )
521
+ t . false ( mockZipFunctions . calls [ 0 ] [ 2 ] . featureFlags . parseWithEsbuild )
522
+ t . is ( mockZipFunctions . calls [ 0 ] [ 2 ] . config . test . schedule , '@daily' )
523
+ t . is ( mockZipFunctions . calls [ 0 ] [ 2 ] . featureFlags . this_is_a_mock_flag , undefined )
524
+ t . is ( mockZipFunctions . calls [ 0 ] [ 2 ] . featureFlags . and_another_one , undefined )
525
525
526
- t . true ( mockZipFunctions . getCall ( 1 ) . args [ 2 ] . featureFlags . traceWithNft )
527
- t . true ( mockZipFunctions . getCall ( 2 ) . args [ 2 ] . featureFlags . parseWithEsbuild )
528
- t . true ( mockZipFunctions . getCall ( 3 ) . args [ 2 ] . featureFlags . this_is_a_mock_flag )
529
- t . true ( mockZipFunctions . getCall ( 3 ) . args [ 2 ] . featureFlags . and_another_one )
526
+ t . true ( mockZipFunctions . calls [ 1 ] [ 2 ] . featureFlags . traceWithNft )
527
+ t . true ( mockZipFunctions . calls [ 2 ] [ 2 ] . featureFlags . parseWithEsbuild )
528
+ t . true ( mockZipFunctions . calls [ 3 ] [ 2 ] . featureFlags . this_is_a_mock_flag )
529
+ t . true ( mockZipFunctions . calls [ 3 ] [ 2 ] . featureFlags . and_another_one )
530
530
} )
531
531
532
532
test ( 'Print warning on lingering processes' , async ( t ) => {
@@ -597,8 +597,8 @@ test('Removes duplicate function names from the list of processed functions', as
597
597
598
598
test . serial ( '`rustTargetDirectory` is passed to zip-it-and-ship-it only when running in buildbot' , async ( t ) => {
599
599
const runCount = 4
600
- const mockZipFunctions = sinon . stub ( ) . resolves ( )
601
- const stub = sinon . stub ( zipItAndShipIt , 'zipFunctions' ) . get ( ( ) => mockZipFunctions )
600
+ const mockZipFunctions = spy ( ( ) => Promise . resolve ( ) )
601
+ const stub = spyOn ( zipItAndShipIt , 'zipFunctions' , mockZipFunctions )
602
602
603
603
await new Fixture ( './fixtures/functions_config_1' ) . withFlags ( { mode : 'buildbot' } ) . runWithBuild ( )
604
604
await new Fixture ( './fixtures/functions_config_1' ) . runWithBuild ( )
@@ -609,10 +609,7 @@ test.serial('`rustTargetDirectory` is passed to zip-it-and-ship-it only when run
609
609
610
610
t . is ( mockZipFunctions . callCount , runCount )
611
611
612
- const { args : call1Args } = mockZipFunctions . getCall ( 0 )
613
- const { args : call2Args } = mockZipFunctions . getCall ( 1 )
614
- const { args : call3Args } = mockZipFunctions . getCall ( 2 )
615
- const { args : call4Args } = mockZipFunctions . getCall ( 3 )
612
+ const [ call1Args , call2Args , call3Args , call4Args ] = mockZipFunctions . calls
616
613
617
614
t . is (
618
615
call1Args [ 2 ] . config [ '*' ] . rustTargetDirectory ,
@@ -628,23 +625,23 @@ test.serial('`rustTargetDirectory` is passed to zip-it-and-ship-it only when run
628
625
629
626
test . serial ( 'configFileDirectories is passed to zip-it-and-ship-it' , async ( t ) => {
630
627
const runCount = 1
631
- const mockZipFunctions = sinon . stub ( ) . resolves ( )
632
- const stub = sinon . stub ( zipItAndShipIt , 'zipFunctions' ) . get ( ( ) => mockZipFunctions )
628
+ const mockZipFunctions = spy ( ( ) => Promise . resolve ( ) )
629
+ const stub = spyOn ( zipItAndShipIt , 'zipFunctions' , mockZipFunctions )
633
630
634
631
await new Fixture ( './fixtures/functions_config_json' ) . withFlags ( { mode : 'buildbot' } ) . runWithBuild ( )
635
632
stub . restore ( )
636
633
637
634
t . is ( mockZipFunctions . callCount , runCount )
638
635
639
- const { args : call1Args } = mockZipFunctions . getCall ( 0 )
636
+ const call1Args = mockZipFunctions . calls [ 0 ]
640
637
641
638
t . deepEqual ( call1Args [ 2 ] . configFileDirectories , [
642
639
join ( FIXTURES_DIR , 'functions_config_json/.netlify/functions-internal' ) ,
643
640
] )
644
641
} )
645
642
646
643
test . serial ( 'functions can have a config with different parameters passed to zip-it-and-ship-it' , async ( t ) => {
647
- const zipItAndShipItSpy = sinon . spy ( zipItAndShipIt , 'zipFunctions' )
644
+ const zipItAndShipItSpy = spyOn ( zipItAndShipIt , 'zipFunctions' )
648
645
const output = await new Fixture ( './fixtures/functions_config_json' )
649
646
. withFlags ( {
650
647
mode : 'buildbot' ,
@@ -653,7 +650,7 @@ test.serial('functions can have a config with different parameters passed to zip
653
650
654
651
zipItAndShipItSpy . restore ( )
655
652
656
- const { args : call1Args } = zipItAndShipItSpy . getCall ( 0 )
653
+ const call1Args = zipItAndShipItSpy . calls [ 0 ]
657
654
const { functions : functions } = await importJsonFile ( call1Args [ 2 ] . manifest )
658
655
659
656
t . is ( functions [ 0 ] . displayName , 'Function One' )
@@ -664,11 +661,11 @@ test.serial('functions can have a config with different parameters passed to zip
664
661
} )
665
662
666
663
test . serial ( 'internalSrcFolder is passed to zip-it-and-ship-it and helps prefill the generator field' , async ( t ) => {
667
- const zipItAndShipItSpy = sinon . spy ( zipItAndShipIt , 'zipFunctions' )
664
+ const zipItAndShipItSpy = spyOn ( zipItAndShipIt , 'zipFunctions' )
668
665
669
666
await new Fixture ( './fixtures/functions_internal_src_folder' ) . withFlags ( { mode : 'buildbot' } ) . runWithBuild ( )
670
667
zipItAndShipItSpy . restore ( )
671
- const { args : call1Args } = zipItAndShipItSpy . getCall ( 0 )
668
+ const call1Args = zipItAndShipItSpy . calls [ 0 ]
672
669
673
670
const [ paths , , options ] = call1Args
674
671
0 commit comments