@@ -22,7 +22,7 @@ test('assets should should be reversed', () => {
22
22
expect ( new AddAssetHtmlPlugin ( [ 'a' , 'b' ] ) . assets ) . toEqual ( [ 'b' , 'a' ] ) ;
23
23
} ) ;
24
24
25
- test . concurrent ( 'should invoke callback on success' , async ( ) => {
25
+ test ( 'should invoke callback on success' , async ( ) => {
26
26
const callback = jest . fn ( ) ;
27
27
28
28
await addAllAssetsToCompilation ( [ ] , { } , pluginMock , callback ) ;
@@ -31,20 +31,19 @@ test.concurrent('should invoke callback on success', async () => {
31
31
expect ( callback ) . toHaveBeenCalledWith ( null , pluginMock ) ;
32
32
} ) ;
33
33
34
- test . concurrent ( 'should invoke callback on error' , async ( ) => {
34
+ test ( 'should invoke callback on error' , async ( ) => {
35
35
const callback = jest . fn ( ) ;
36
36
const compilation = { errors : [ ] } ;
37
37
38
38
await addAllAssetsToCompilation ( [ { } ] , compilation , pluginMock , callback ) ;
39
39
40
- expect ( compilation . errors ) . toHaveLength ( 1 ) ;
41
- expect ( compilation . errors [ 0 ] . message ) . toBe ( 'No filepath defined' ) ;
40
+ expect ( compilation . errors ) . toMatchSnapshot ( ) ;
42
41
43
42
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
44
43
expect ( callback ) . toHaveBeenCalledWith ( compilation . errors [ 0 ] , pluginMock ) ;
45
44
} ) ;
46
45
47
- test . concurrent ( "should add file using compilation's publicPath" , async ( ) => {
46
+ test ( "should add file using compilation's publicPath" , async ( ) => {
48
47
const callback = jest . fn ( ) ;
49
48
const compilation = { options : { output : { publicPath : 'vendor/' } } } ;
50
49
const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
@@ -56,22 +55,20 @@ test.concurrent("should add file using compilation's publicPath", async () => {
56
55
callback
57
56
) ;
58
57
59
- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
60
- expect ( pluginData . assets . js ) . toEqual ( [ 'vendor/my-file.js' ] ) ;
58
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
61
59
62
60
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
63
61
expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
64
62
} ) ;
65
63
66
- test . concurrent ( 'should used passed in publicPath' , async ( ) => {
64
+ test ( 'should used passed in publicPath' , async ( ) => {
67
65
const callback = jest . fn ( ) ;
68
66
const compilation = { options : { output : { publicPath : 'vendor/' } } } ;
69
67
const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
70
68
71
69
await addAllAssetsToCompilation ( [ { filepath : 'my-file.js' , publicPath : 'pp' } ] , compilation , pluginData , callback ) ;
72
70
73
- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
74
- expect ( pluginData . assets . js ) . toEqual ( [ 'pp/my-file.js' ] ) ;
71
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
75
72
76
73
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
77
74
expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
@@ -80,21 +77,20 @@ test.concurrent('should used passed in publicPath', async () => {
80
77
// TODO: No idea what this does, actually... Coverage currently hits it, but the logic is untested.
81
78
test ( 'should handle missing `publicPath`' ) ;
82
79
83
- test . concurrent ( 'should add file missing "/" to public path' , async ( ) => {
80
+ test ( 'should add file missing "/" to public path' , async ( ) => {
84
81
const callback = jest . fn ( ) ;
85
82
const compilation = { options : { output : { publicPath : 'vendor' } } } ;
86
83
const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
87
84
88
85
await addAllAssetsToCompilation ( [ { filepath : 'my-file.js' } ] , compilation , pluginData , callback ) ;
89
86
90
- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
91
- expect ( pluginData . assets . js ) . toEqual ( [ 'vendor/my-file.js' ] ) ;
87
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
92
88
93
89
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
94
90
expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
95
91
} ) ;
96
92
97
- test . concurrent ( 'should add sourcemap to compilation' , async ( ) => {
93
+ test ( 'should add sourcemap to compilation' , async ( ) => {
98
94
const callback = jest . fn ( ) ;
99
95
const addFileToAssetsStub = jest . fn ( ) ;
100
96
const compilation = { options : { output : { } } } ;
@@ -103,8 +99,7 @@ test.concurrent('should add sourcemap to compilation', async () => {
103
99
104
100
await addAllAssetsToCompilation ( [ { filepath : 'my-file.js' } ] , compilation , pluginData , callback ) ;
105
101
106
- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
107
- expect ( pluginData . assets . js ) . toEqual ( [ 'my-file.js' ] ) ;
102
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
108
103
109
104
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
110
105
expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
@@ -114,7 +109,7 @@ test.concurrent('should add sourcemap to compilation', async () => {
114
109
expect ( addFileToAssetsStub . mock . calls [ 1 ] ) . toEqual ( [ 'my-file.js.map' , compilation ] ) ;
115
110
} ) ;
116
111
117
- test . concurrent ( 'should skip adding sourcemap to compilation if set to false' , async ( ) => {
112
+ test ( 'should skip adding sourcemap to compilation if set to false' , async ( ) => {
118
113
const callback = jest . fn ( ) ;
119
114
const addFileToAssetsStub = jest . fn ( ) ;
120
115
const compilation = { options : { output : { } } } ;
@@ -128,8 +123,7 @@ test.concurrent('should skip adding sourcemap to compilation if set to false', a
128
123
callback
129
124
) ;
130
125
131
- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
132
- expect ( pluginData . assets . js ) . toEqual ( [ 'my-file.js' ] ) ;
126
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
133
127
134
128
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
135
129
expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
@@ -138,7 +132,7 @@ test.concurrent('should skip adding sourcemap to compilation if set to false', a
138
132
expect ( addFileToAssetsStub ) . toHaveBeenCalledWith ( 'my-file.js' , compilation ) ;
139
133
} ) ;
140
134
141
- test . concurrent ( 'should include hash of file content if option is set' , async ( ) => {
135
+ test ( 'should include hash of file content if option is set' , async ( ) => {
142
136
const callback = jest . fn ( ) ;
143
137
const compilation = {
144
138
options : { output : { } } ,
@@ -148,14 +142,13 @@ test.concurrent('should include hash of file content if option is set', async ()
148
142
149
143
await addAllAssetsToCompilation ( [ { filepath : 'my-file.js' , hash : true } ] , compilation , pluginData , callback ) ;
150
144
151
- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
152
- expect ( pluginData . assets . js ) . toEqual ( [ 'my-file.js?5329c141291f07ab06c6' ] ) ;
145
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
153
146
154
147
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
155
148
expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
156
149
} ) ;
157
150
158
- test . concurrent ( 'should add to css if `typeOfAsset` is css' , async ( ) => {
151
+ test ( 'should add to css if `typeOfAsset` is css' , async ( ) => {
159
152
const callback = jest . fn ( ) ;
160
153
const compilation = {
161
154
options : { output : { } } ,
@@ -165,14 +158,13 @@ test.concurrent('should add to css if `typeOfAsset` is css', async () => {
165
158
166
159
await addAllAssetsToCompilation ( [ { filepath : 'my-file.css' , typeOfAsset : 'css' } ] , compilation , pluginData , callback ) ;
167
160
168
- expect ( pluginData . assets . css ) . toEqual ( [ 'my-file.css' ] ) ;
169
- expect ( pluginData . assets . js ) . toEqual ( [ ] ) ;
161
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
170
162
171
163
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
172
164
expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
173
165
} ) ;
174
166
175
- test . concurrent ( 'should replace compilation assets key if `outputPath` is set' , async ( ) => {
167
+ test ( 'should replace compilation assets key if `outputPath` is set' , async ( ) => {
176
168
const callback = jest . fn ( ) ;
177
169
const source = { source : ( ) => 'test' } ;
178
170
const addFileToAssetsMock = ( filename , compilation ) => {
@@ -193,16 +185,15 @@ test.concurrent('should replace compilation assets key if `outputPath` is set',
193
185
callback
194
186
) ;
195
187
196
- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
197
- expect ( pluginData . assets . js ) . toEqual ( [ 'my-file.js' ] ) ;
188
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
198
189
199
190
expect ( compilation . assets [ 'my-file.js' ] ) . toBeUndefined ( ) ;
200
191
expect ( compilation . assets [ 'assets/my-file.js' ] ) . toEqual ( source ) ;
201
192
expect ( compilation . assets [ 'my-file.js.map' ] ) . toBeUndefined ( ) ;
202
193
expect ( compilation . assets [ 'assets/my-file.js.map' ] ) . toEqual ( source ) ;
203
194
} ) ;
204
195
205
- test . concurrent ( 'filter option should exclude some files' , async ( ) => {
196
+ test ( 'filter option should exclude some files' , async ( ) => {
206
197
const callback = jest . fn ( ) ;
207
198
const compilation = { options : { output : { publicPath : 'vendor/' } } } ;
208
199
const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
@@ -214,14 +205,13 @@ test.concurrent('filter option should exclude some files', async () => {
214
205
callback
215
206
) ;
216
207
217
- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
218
- expect ( pluginData . assets . js ) . toEqual ( [ ] ) ;
208
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
219
209
220
210
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
221
211
expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
222
212
} ) ;
223
213
224
- test . concurrent ( 'filter option should include some files' , async ( ) => {
214
+ test ( 'filter option should include some files' , async ( ) => {
225
215
const callback = jest . fn ( ) ;
226
216
const compilation = { options : { output : { publicPath : 'vendor/' } } } ;
227
217
const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
@@ -233,8 +223,7 @@ test.concurrent('filter option should include some files', async () => {
233
223
callback
234
224
) ;
235
225
236
- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
237
- expect ( pluginData . assets . js ) . toEqual ( [ 'vendor/my-file.js' ] ) ;
226
+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
238
227
239
228
expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
240
229
expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
0 commit comments