@@ -11,18 +11,16 @@ test.beforeEach(async (t) => {
1111 notify : t . context . updateNotifierNotify
1212 } ) . named ( "updateNotifier" ) ;
1313
14- t . context . argvGetter = sinon . stub ( ) ;
14+ t . context . yargsHideBin = sinon . stub ( ) . named ( "hideBin" ) . returns ( [ ] ) ;
15+
1516 t . context . yargsInstance = {
1617 parserConfiguration : sinon . stub ( ) ,
1718 version : sinon . stub ( ) ,
1819 scriptName : sinon . stub ( ) ,
1920 command : sinon . stub ( ) ,
2021 terminalWidth : sinon . stub ( ) . returns ( 123 ) ,
2122 wrap : sinon . stub ( ) ,
22- get argv ( ) {
23- t . context . argvGetter ( ) ;
24- return undefined ;
25- }
23+ parse : sinon . stub ( ) . resolves ( { _ : [ ] } )
2624 } ;
2725
2826 t . context . yargs = sinon . stub ( ) . returns ( t . context . yargsInstance ) . named ( "yargs" ) ;
@@ -54,10 +52,9 @@ test.beforeEach(async (t) => {
5452 t . context . cli = await esmock . p ( "../../../lib/cli/cli.js" , {
5553 "update-notifier" : t . context . updateNotifier ,
5654 "yargs" : t . context . yargs ,
57- // TODO: Somehow esmock is unable to mock this import
58- // "yargs/helpers": {
59- // hideBin: t.context.yargsHideBin
60- // },
55+ "yargs/helpers" : {
56+ hideBin : t . context . yargsHideBin
57+ } ,
6158 "../../../lib/cli/version.js" : {
6259 setVersion : t . context . setVersion
6360 } ,
@@ -76,7 +73,7 @@ test.afterEach.always((t) => {
7673
7774test . serial ( "CLI" , async ( t ) => {
7875 const {
79- cli, updateNotifier, updateNotifierNotify, argvGetter , yargsInstance, yargs,
76+ cli, updateNotifier, updateNotifierNotify, yargsInstance, yargs,
8077 setVersion, cliBase
8178 } = t . context ;
8279
@@ -131,8 +128,8 @@ test.serial("CLI", async (t) => {
131128 t . is ( yargsInstance . wrap . callCount , 1 ) ;
132129 t . deepEqual ( yargsInstance . wrap . getCall ( 0 ) . args , [ 123 ] ) ;
133130
134- t . is ( argvGetter . callCount , 1 ) ;
135- t . deepEqual ( argvGetter . getCall ( 0 ) . args , [ ] ) ;
131+ t . is ( yargsInstance . parse . callCount , 1 ) ;
132+ t . deepEqual ( yargsInstance . parse . getCall ( 0 ) . args , [ ] ) ;
136133
137134 sinon . assert . callOrder (
138135 updateNotifier ,
@@ -146,7 +143,7 @@ test.serial("CLI", async (t) => {
146143 yargsInstance . command ,
147144 yargsInstance . terminalWidth ,
148145 yargsInstance . wrap ,
149- argvGetter
146+ yargsInstance . parse
150147 ) ;
151148} ) ;
152149
0 commit comments