@@ -8,14 +8,11 @@ const actionChainMock = jest.fn();
88jest . unstable_mockModule ( 'src/actions/actionChainWithProgress.js' , ( ) => ( {
99 createChainWithProgress : ( ) => actionChainMock ,
1010} ) ) ;
11- const assertUserConfirmationMock = jest . fn ( ) ;
12- const getAnswersFromUserMock = jest . fn ( ) ;
1311jest . unstable_mockModule ( 'src/actions/index.js' , ( ) => ( {
14- assertUserConfirmation : ( ) => assertUserConfirmationMock ,
15- getAnswersFromUser : ( ) => getAnswersFromUserMock ,
12+ assertUserConfirmation : jest . fn ( ) ,
13+ getAnswersFromUser : jest . fn ( ) ,
1614} ) ) ;
1715jest . unstable_mockModule ( 'src/festive.js' , ( ) => ( {
18- festiveEmoji : jest . fn ( ) ,
1916 festiveStyle : jest . fn ( ) ,
2017 printFestiveTitle : jest . fn ( ) ,
2118} ) ) ;
@@ -31,10 +28,13 @@ jest.unstable_mockModule('src/initialize/index.js', () => ({
3128 installPackages : jest . fn ( ) ,
3229} ) ) ;
3330jest . unstable_mockModule ( 'src/cli/auth.js' , ( ) => ( {
34- authTokenQuestion : ( ) => jest . fn ( ) ,
31+ authTokenQuestion : { } ,
3532} ) ) ;
3633
3734// import after mocks set up.
35+ const { assertUserConfirmation, getAnswersFromUser } = await import (
36+ '../../src/actions/index.js'
37+ ) ;
3838const { cwdIsEmpty } = await import ( '../../src/initialize/index.js' ) ;
3939
4040describe ( 'initialize command' , ( ) => {
@@ -51,32 +51,32 @@ describe('initialize command', () => {
5151 test ( 'does not ask for confirmation if cwd is empty' , async ( ) => {
5252 const { initializeAction } = await import ( '../../src/cli/initialize.js' ) ;
5353 cwdIsEmpty . mockResolvedValue ( true ) ;
54- getAnswersFromUserMock . mockResolvedValue ( { answers : { } } ) ;
54+ assertUserConfirmation . mockResolvedValue ( { } ) ;
5555 await initializeAction ( ) ;
56- expect ( assertUserConfirmationMock ) . not . toHaveBeenCalled ( ) ;
56+ expect ( assertUserConfirmation ) . not . toHaveBeenCalled ( ) ;
5757 } ) ;
5858
5959 test ( 'asks for confirmation if cwd is not empty' , async ( ) => {
6060 const { initializeAction } = await import ( '../../src/cli/initialize.js' ) ;
6161 cwdIsEmpty . mockResolvedValue ( false ) ;
62- assertUserConfirmationMock . mockResolvedValue ( false ) ;
62+ assertUserConfirmation . mockResolvedValue ( false ) ;
6363 await initializeAction ( ) ;
64- expect ( assertUserConfirmationMock ) . toHaveBeenCalled ( ) ;
64+ expect ( assertUserConfirmation ) . toHaveBeenCalled ( ) ;
6565 } ) ;
6666
6767 test ( 'aborts if user does not confirm' , async ( ) => {
6868 const { initializeAction } = await import ( '../../src/cli/initialize.js' ) ;
6969 cwdIsEmpty . mockResolvedValue ( false ) ;
70- assertUserConfirmationMock . mockResolvedValue ( false ) ;
70+ assertUserConfirmation . mockResolvedValue ( false ) ;
7171 await initializeAction ( ) ;
7272 expect ( actionChainMock ) . not . toHaveBeenCalled ( ) ;
7373 } ) ;
7474
7575 test ( 'continues if user confirms' , async ( ) => {
7676 const { initializeAction } = await import ( '../../src/cli/initialize.js' ) ;
7777 cwdIsEmpty . mockResolvedValue ( false ) ;
78- assertUserConfirmationMock . mockResolvedValue ( true ) ;
79- getAnswersFromUserMock . mockResolvedValue ( { answers : { } } ) ;
78+ assertUserConfirmation . mockResolvedValue ( true ) ;
79+ getAnswersFromUser . mockResolvedValue ( { answers : { } } ) ;
8080 await initializeAction ( ) ;
8181 expect ( actionChainMock ) . toHaveBeenCalled ( ) ;
8282 } ) ;
0 commit comments