@@ -6,7 +6,7 @@ const Reader = require('../');
6
6
const SinkFs = require ( 'asset-pipe-sink-fs' ) ;
7
7
const path = require ( 'path' ) ;
8
8
const { sort, dedupe, compareByOrder } = require ( '../lib/util' ) ;
9
- const { Readable, PassThrough } = require ( 'stream' ) ;
9
+ const { Readable, PassThrough } = require ( 'readable- stream' ) ;
10
10
11
11
function createSlowStream ( sink , filePath , timeout = 1000 ) {
12
12
const myStream = new PassThrough ( ) ;
@@ -76,7 +76,7 @@ test('Dedupe of identical hashes occurs', done => {
76
76
const bundle = [ ] ;
77
77
reader . on ( 'data' , data => bundle . push ( data . toString ( ) ) ) ;
78
78
reader . on ( 'end' , ( ) => {
79
- expect ( bundle . length ) . toBe ( 1 ) ;
79
+ expect ( bundle ) . toHaveLength ( 1 ) ;
80
80
done ( ) ;
81
81
} ) ;
82
82
} ) ;
@@ -216,13 +216,13 @@ test('SortAndDedupe() rows without id value dropped', done => {
216
216
. pipe ( dedupe ( ) )
217
217
. on ( 'data' , data => buffer . push ( data ) )
218
218
. on ( 'end' , ( ) => {
219
- expect ( buffer . length ) . toBe ( 2 ) ;
219
+ expect ( buffer ) . toHaveLength ( 2 ) ;
220
220
done ( ) ;
221
221
} ) ;
222
222
} ) ;
223
223
224
224
test ( 'new Reader([s1,s2,s3,s4]) ensure dedupe and correct css concat order' , done => {
225
- expect . assertions ( 3 ) ;
225
+ expect . assertions ( 1 ) ;
226
226
const sink = new SinkFs ( {
227
227
path : path . join ( __dirname , './test-assets' ) ,
228
228
} ) ;
@@ -237,16 +237,18 @@ test('new Reader([s1,s2,s3,s4]) ensure dedupe and correct css concat order', don
237
237
const bundle = [ ] ;
238
238
reader . on ( 'data' , data => bundle . push ( data . toString ( ) ) ) ;
239
239
reader . on ( 'end' , ( ) => {
240
- expect ( bundle [ 0 ] ) . toBe ( '/* my-module-3/main.css */\n\n/* my-module-3/dep.css */\n\n/* dep/main.css */\n' ) ;
241
- expect ( bundle [ 1 ] ) . toBe ( '/* my-module-2/main.css */\n' ) ;
242
- expect ( bundle [ 2 ] ) . toBe ( '/* my-module-1/main.css */\n' ) ;
240
+ expect ( bundle ) . toEqual ( [
241
+ '/* my-module-3/main.css */\n\n/* my-module-3/dep.css */\n\n/* dep/main.css */\n' ,
242
+ '/* my-module-2/main.css */\n' ,
243
+ '/* my-module-1/main.css */\n' ,
244
+ ] ) ;
243
245
done ( ) ;
244
246
} ) ;
245
247
} ) ;
246
248
} ) ;
247
249
248
250
test ( 'new Reader([s1,s2,s3,s4]) operates correctly under slow speed conditions' , done => {
249
- expect . assertions ( 3 ) ;
251
+ expect . assertions ( 1 ) ;
250
252
const sink = new SinkFs ( {
251
253
path : path . join ( __dirname , './test-assets' ) ,
252
254
} ) ;
@@ -262,9 +264,11 @@ test('new Reader([s1,s2,s3,s4]) operates correctly under slow speed conditions',
262
264
const bundle = [ ] ;
263
265
reader . on ( 'data' , data => bundle . push ( data . toString ( ) ) ) ;
264
266
reader . on ( 'end' , ( ) => {
265
- expect ( bundle [ 0 ] ) . toBe ( '/* my-module-3/main.css */\n\n/* my-module-3/dep.css */\n\n/* dep/main.css */\n' ) ;
266
- expect ( bundle [ 1 ] ) . toBe ( '/* my-module-2/main.css */\n' ) ;
267
- expect ( bundle [ 2 ] ) . toBe ( '/* my-module-1/main.css */\n' ) ;
267
+ expect ( bundle ) . toEqual ( [
268
+ '/* my-module-3/main.css */\n\n/* my-module-3/dep.css */\n\n/* dep/main.css */\n' ,
269
+ '/* my-module-2/main.css */\n' ,
270
+ '/* my-module-1/main.css */\n' ,
271
+ ] ) ;
268
272
done ( ) ;
269
273
} ) ;
270
274
} ) ;
@@ -294,7 +298,7 @@ test('sort() transform operating on stream items without order property', done =
294
298
. pipe ( sort ( ) )
295
299
. on ( 'data' , data => buffer . push ( data ) )
296
300
. on ( 'end' , ( ) => {
297
- expect ( buffer . length ) . toBe ( 1 ) ;
301
+ expect ( buffer ) . toHaveLength ( 1 ) ;
298
302
done ( ) ;
299
303
} ) ;
300
304
} ) ;
0 commit comments