@@ -22,26 +22,56 @@ describe('NPM Proxy', () => {
2222 } ) ;
2323
2424 describe ( 'installDependencies' , ( ) => {
25- it ( 'should run `npm install`' , ( ) => {
26- const executeCommandSpy = jest . spyOn ( npmProxy , 'executeCommand' ) . mockReturnValue ( '' ) ;
25+ describe ( 'npm6' , ( ) => {
26+ it ( 'should run `npm install`' , ( ) => {
27+ const executeCommandSpy = jest . spyOn ( npmProxy , 'executeCommand' ) . mockReturnValue ( '6.0.0' ) ;
2728
28- npmProxy . installDependencies ( ) ;
29+ npmProxy . installDependencies ( ) ;
2930
30- expect ( executeCommandSpy ) . toHaveBeenCalledWith ( 'npm' , [ 'install' ] , expect . any ( String ) ) ;
31+ expect ( executeCommandSpy ) . toHaveBeenLastCalledWith ( 'npm' , [ 'install' ] , expect . any ( String ) ) ;
32+ } ) ;
33+ } ) ;
34+ describe ( 'npm7' , ( ) => {
35+ it ( 'should run `npm install --legacy-peer-deps`' , ( ) => {
36+ const executeCommandSpy = jest . spyOn ( npmProxy , 'executeCommand' ) . mockReturnValue ( '7.1.0' ) ;
37+
38+ npmProxy . installDependencies ( ) ;
39+
40+ expect ( executeCommandSpy ) . toHaveBeenLastCalledWith (
41+ 'npm' ,
42+ [ 'install' , '--legacy-peer-deps' ] ,
43+ expect . any ( String )
44+ ) ;
45+ } ) ;
3146 } ) ;
3247 } ) ;
3348
3449 describe ( 'addDependencies' , ( ) => {
35- it ( 'with devDep it should run `npm install -D @storybook/addons`' , ( ) => {
36- const executeCommandSpy = jest . spyOn ( npmProxy , 'executeCommand' ) . mockReturnValue ( '' ) ;
37-
38- npmProxy . addDependencies ( { installAsDevDependencies : true } , [ '@storybook/addons' ] ) ;
39-
40- expect ( executeCommandSpy ) . toHaveBeenCalledWith (
41- 'npm' ,
42- [ 'install' , '-D' , '@storybook/addons' ] ,
43- expect . any ( String )
44- ) ;
50+ describe ( 'npm6' , ( ) => {
51+ it ( 'with devDep it should run `npm install -D @storybook/addons`' , ( ) => {
52+ const executeCommandSpy = jest . spyOn ( npmProxy , 'executeCommand' ) . mockReturnValue ( '6.0.0' ) ;
53+
54+ npmProxy . addDependencies ( { installAsDevDependencies : true } , [ '@storybook/addons' ] ) ;
55+
56+ expect ( executeCommandSpy ) . toHaveBeenLastCalledWith (
57+ 'npm' ,
58+ [ 'install' , '-D' , '@storybook/addons' ] ,
59+ expect . any ( String )
60+ ) ;
61+ } ) ;
62+ } ) ;
63+ describe ( 'npm7' , ( ) => {
64+ it ( 'with devDep it should run `npm install -D @storybook/addons`' , ( ) => {
65+ const executeCommandSpy = jest . spyOn ( npmProxy , 'executeCommand' ) . mockReturnValue ( '7.0.0' ) ;
66+
67+ npmProxy . addDependencies ( { installAsDevDependencies : true } , [ '@storybook/addons' ] ) ;
68+
69+ expect ( executeCommandSpy ) . toHaveBeenLastCalledWith (
70+ 'npm' ,
71+ [ 'install' , '--legacy-peer-deps' , '-D' , '@storybook/addons' ] ,
72+ expect . any ( String )
73+ ) ;
74+ } ) ;
4575 } ) ;
4676 } ) ;
4777
0 commit comments