@@ -22,7 +22,7 @@ test('assets should should be reversed', () => {
2222 expect ( new AddAssetHtmlPlugin ( [ 'a' , 'b' ] ) . assets ) . toEqual ( [ 'b' , 'a' ] ) ;
2323} ) ;
2424
25- test . concurrent ( 'should invoke callback on success' , async ( ) => {
25+ test ( 'should invoke callback on success' , async ( ) => {
2626 const callback = jest . fn ( ) ;
2727
2828 await addAllAssetsToCompilation ( [ ] , { } , pluginMock , callback ) ;
@@ -31,20 +31,19 @@ test.concurrent('should invoke callback on success', async () => {
3131 expect ( callback ) . toHaveBeenCalledWith ( null , pluginMock ) ;
3232} ) ;
3333
34- test . concurrent ( 'should invoke callback on error' , async ( ) => {
34+ test ( 'should invoke callback on error' , async ( ) => {
3535 const callback = jest . fn ( ) ;
3636 const compilation = { errors : [ ] } ;
3737
3838 await addAllAssetsToCompilation ( [ { } ] , compilation , pluginMock , callback ) ;
3939
40- expect ( compilation . errors ) . toHaveLength ( 1 ) ;
41- expect ( compilation . errors [ 0 ] . message ) . toBe ( 'No filepath defined' ) ;
40+ expect ( compilation . errors ) . toMatchSnapshot ( ) ;
4241
4342 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
4443 expect ( callback ) . toHaveBeenCalledWith ( compilation . errors [ 0 ] , pluginMock ) ;
4544} ) ;
4645
47- test . concurrent ( "should add file using compilation's publicPath" , async ( ) => {
46+ test ( "should add file using compilation's publicPath" , async ( ) => {
4847 const callback = jest . fn ( ) ;
4948 const compilation = { options : { output : { publicPath : 'vendor/' } } } ;
5049 const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
@@ -56,22 +55,20 @@ test.concurrent("should add file using compilation's publicPath", async () => {
5655 callback
5756 ) ;
5857
59- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
60- expect ( pluginData . assets . js ) . toEqual ( [ 'vendor/my-file.js' ] ) ;
58+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
6159
6260 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
6361 expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
6462} ) ;
6563
66- test . concurrent ( 'should used passed in publicPath' , async ( ) => {
64+ test ( 'should used passed in publicPath' , async ( ) => {
6765 const callback = jest . fn ( ) ;
6866 const compilation = { options : { output : { publicPath : 'vendor/' } } } ;
6967 const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
7068
7169 await addAllAssetsToCompilation ( [ { filepath : 'my-file.js' , publicPath : 'pp' } ] , compilation , pluginData , callback ) ;
7270
73- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
74- expect ( pluginData . assets . js ) . toEqual ( [ 'pp/my-file.js' ] ) ;
71+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
7572
7673 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
7774 expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
@@ -80,21 +77,20 @@ test.concurrent('should used passed in publicPath', async () => {
8077// TODO: No idea what this does, actually... Coverage currently hits it, but the logic is untested.
8178test ( 'should handle missing `publicPath`' ) ;
8279
83- test . concurrent ( 'should add file missing "/" to public path' , async ( ) => {
80+ test ( 'should add file missing "/" to public path' , async ( ) => {
8481 const callback = jest . fn ( ) ;
8582 const compilation = { options : { output : { publicPath : 'vendor' } } } ;
8683 const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
8784
8885 await addAllAssetsToCompilation ( [ { filepath : 'my-file.js' } ] , compilation , pluginData , callback ) ;
8986
90- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
91- expect ( pluginData . assets . js ) . toEqual ( [ 'vendor/my-file.js' ] ) ;
87+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
9288
9389 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
9490 expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
9591} ) ;
9692
97- test . concurrent ( 'should add sourcemap to compilation' , async ( ) => {
93+ test ( 'should add sourcemap to compilation' , async ( ) => {
9894 const callback = jest . fn ( ) ;
9995 const addFileToAssetsStub = jest . fn ( ) ;
10096 const compilation = { options : { output : { } } } ;
@@ -103,8 +99,7 @@ test.concurrent('should add sourcemap to compilation', async () => {
10399
104100 await addAllAssetsToCompilation ( [ { filepath : 'my-file.js' } ] , compilation , pluginData , callback ) ;
105101
106- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
107- expect ( pluginData . assets . js ) . toEqual ( [ 'my-file.js' ] ) ;
102+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
108103
109104 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
110105 expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
@@ -114,7 +109,7 @@ test.concurrent('should add sourcemap to compilation', async () => {
114109 expect ( addFileToAssetsStub . mock . calls [ 1 ] ) . toEqual ( [ 'my-file.js.map' , compilation ] ) ;
115110} ) ;
116111
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 ( ) => {
118113 const callback = jest . fn ( ) ;
119114 const addFileToAssetsStub = jest . fn ( ) ;
120115 const compilation = { options : { output : { } } } ;
@@ -128,8 +123,7 @@ test.concurrent('should skip adding sourcemap to compilation if set to false', a
128123 callback
129124 ) ;
130125
131- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
132- expect ( pluginData . assets . js ) . toEqual ( [ 'my-file.js' ] ) ;
126+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
133127
134128 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
135129 expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
@@ -138,7 +132,7 @@ test.concurrent('should skip adding sourcemap to compilation if set to false', a
138132 expect ( addFileToAssetsStub ) . toHaveBeenCalledWith ( 'my-file.js' , compilation ) ;
139133} ) ;
140134
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 ( ) => {
142136 const callback = jest . fn ( ) ;
143137 const compilation = {
144138 options : { output : { } } ,
@@ -148,14 +142,13 @@ test.concurrent('should include hash of file content if option is set', async ()
148142
149143 await addAllAssetsToCompilation ( [ { filepath : 'my-file.js' , hash : true } ] , compilation , pluginData , callback ) ;
150144
151- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
152- expect ( pluginData . assets . js ) . toEqual ( [ 'my-file.js?5329c141291f07ab06c6' ] ) ;
145+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
153146
154147 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
155148 expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
156149} ) ;
157150
158- test . concurrent ( 'should add to css if `typeOfAsset` is css' , async ( ) => {
151+ test ( 'should add to css if `typeOfAsset` is css' , async ( ) => {
159152 const callback = jest . fn ( ) ;
160153 const compilation = {
161154 options : { output : { } } ,
@@ -165,14 +158,13 @@ test.concurrent('should add to css if `typeOfAsset` is css', async () => {
165158
166159 await addAllAssetsToCompilation ( [ { filepath : 'my-file.css' , typeOfAsset : 'css' } ] , compilation , pluginData , callback ) ;
167160
168- expect ( pluginData . assets . css ) . toEqual ( [ 'my-file.css' ] ) ;
169- expect ( pluginData . assets . js ) . toEqual ( [ ] ) ;
161+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
170162
171163 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
172164 expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
173165} ) ;
174166
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 ( ) => {
176168 const callback = jest . fn ( ) ;
177169 const source = { source : ( ) => 'test' } ;
178170 const addFileToAssetsMock = ( filename , compilation ) => {
@@ -193,16 +185,15 @@ test.concurrent('should replace compilation assets key if `outputPath` is set',
193185 callback
194186 ) ;
195187
196- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
197- expect ( pluginData . assets . js ) . toEqual ( [ 'my-file.js' ] ) ;
188+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
198189
199190 expect ( compilation . assets [ 'my-file.js' ] ) . toBeUndefined ( ) ;
200191 expect ( compilation . assets [ 'assets/my-file.js' ] ) . toEqual ( source ) ;
201192 expect ( compilation . assets [ 'my-file.js.map' ] ) . toBeUndefined ( ) ;
202193 expect ( compilation . assets [ 'assets/my-file.js.map' ] ) . toEqual ( source ) ;
203194} ) ;
204195
205- test . concurrent ( 'filter option should exclude some files' , async ( ) => {
196+ test ( 'filter option should exclude some files' , async ( ) => {
206197 const callback = jest . fn ( ) ;
207198 const compilation = { options : { output : { publicPath : 'vendor/' } } } ;
208199 const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
@@ -214,14 +205,13 @@ test.concurrent('filter option should exclude some files', async () => {
214205 callback
215206 ) ;
216207
217- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
218- expect ( pluginData . assets . js ) . toEqual ( [ ] ) ;
208+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
219209
220210 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
221211 expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
222212} ) ;
223213
224- test . concurrent ( 'filter option should include some files' , async ( ) => {
214+ test ( 'filter option should include some files' , async ( ) => {
225215 const callback = jest . fn ( ) ;
226216 const compilation = { options : { output : { publicPath : 'vendor/' } } } ;
227217 const pluginData = Object . assign ( { assets : { js : [ ] , css : [ ] } } , pluginMock ) ;
@@ -233,8 +223,7 @@ test.concurrent('filter option should include some files', async () => {
233223 callback
234224 ) ;
235225
236- expect ( pluginData . assets . css ) . toEqual ( [ ] ) ;
237- expect ( pluginData . assets . js ) . toEqual ( [ 'vendor/my-file.js' ] ) ;
226+ expect ( pluginData . assets ) . toMatchSnapshot ( ) ;
238227
239228 expect ( callback ) . toHaveBeenCalledTimes ( 1 ) ;
240229 expect ( callback ) . toHaveBeenCalledWith ( null , pluginData ) ;
0 commit comments