@@ -15,8 +15,6 @@ const mockFs = {
15
15
} ,
16
16
} ;
17
17
18
- mock . method ( require ( 'fs' ) , 'writeFileSync' , mockFs . writeFileSync ) ;
19
-
20
18
describe ( 'loader' , ( ) => {
21
19
beforeEach ( ( ) => {
22
20
pathMock = undefined ;
@@ -26,7 +24,10 @@ describe('loader', () => {
26
24
describe ( 'writeRequires' , ( ) => {
27
25
describe ( 'when there is a story glob' , ( ) => {
28
26
it ( 'writes the story imports' , async ( t ) => {
27
+ mock . method ( require ( 'fs' ) , 'writeFileSync' , mockFs . writeFileSync ) ;
29
28
await generate ( { configPath : 'scripts/mocks/all-config-files' } ) ;
29
+ mock . reset ( ) ;
30
+
30
31
assert . strictEqual (
31
32
pathMock ,
32
33
path . resolve ( __dirname , 'mocks/all-config-files/storybook.requires.ts' )
@@ -37,7 +38,10 @@ describe('loader', () => {
37
38
38
39
describe ( 'when using js' , ( ) => {
39
40
it ( 'writes the story imports without types' , async ( t ) => {
41
+ mock . method ( require ( 'fs' ) , 'writeFileSync' , mockFs . writeFileSync ) ;
40
42
await generate ( { configPath : 'scripts/mocks/all-config-files' , useJs : true } ) ;
43
+ mock . reset ( ) ;
44
+
41
45
assert . strictEqual (
42
46
pathMock ,
43
47
path . resolve ( __dirname , 'mocks/all-config-files/storybook.requires.js' )
@@ -48,7 +52,10 @@ describe('loader', () => {
48
52
49
53
describe ( 'when there are different file extensions' , ( ) => {
50
54
it ( 'writes the story imports' , async ( t ) => {
55
+ mock . method ( require ( 'fs' ) , 'writeFileSync' , mockFs . writeFileSync ) ;
51
56
await generate ( { configPath : 'scripts/mocks/file-extensions' } ) ;
57
+ mock . reset ( ) ;
58
+
52
59
assert . strictEqual (
53
60
pathMock ,
54
61
path . resolve ( __dirname , 'mocks/file-extensions/storybook.requires.ts' )
@@ -75,16 +82,21 @@ describe('loader', () => {
75
82
76
83
describe ( 'when there is no story glob or addons' , ( ) => {
77
84
it ( 'throws an error' , async ( ) => {
85
+ mock . method ( require ( 'fs' ) , 'writeFileSync' , mockFs . writeFileSync ) ;
78
86
await assert . rejects (
79
87
async ( ) => await generate ( { configPath : 'scripts/mocks/blank-config' } ) ,
80
88
Error
81
89
) ;
90
+ mock . reset ( ) ;
82
91
} ) ;
83
92
} ) ;
84
93
85
94
describe ( 'when there is no preview' , ( ) => {
86
95
it ( 'does not add preview related stuff' , async ( t ) => {
96
+ mock . method ( require ( 'fs' ) , 'writeFileSync' , mockFs . writeFileSync ) ;
87
97
await generate ( { configPath : 'scripts/mocks/no-preview' } ) ;
98
+ mock . reset ( ) ;
99
+
88
100
assert . strictEqual (
89
101
pathMock ,
90
102
path . resolve ( __dirname , 'mocks/no-preview/storybook.requires.ts' )
@@ -109,7 +121,10 @@ describe('loader', () => {
109
121
110
122
describe ( 'when there is a configuration object' , ( ) => {
111
123
it ( 'writes the story imports' , async ( t ) => {
124
+ mock . method ( require ( 'fs' ) , 'writeFileSync' , mockFs . writeFileSync ) ;
112
125
await generate ( { configPath : 'scripts/mocks/configuration-objects' } ) ;
126
+ mock . reset ( ) ;
127
+
113
128
assert . strictEqual (
114
129
pathMock ,
115
130
path . resolve ( __dirname , 'mocks/configuration-objects/storybook.requires.ts' )
0 commit comments