@@ -230,23 +230,46 @@ describe('gulp-cleaner-css: base functionality', () => {
230230
231231 it ( 'should invoke a plugin error: streaming not supported' , done => {
232232
233- gulp . src ( 'test/fixtures/test.css' , { buffer : false } )
234- . pipe ( cleanCSS ( )
235- . on ( 'error' , err => {
236- expect ( err . message ) . to . equal ( 'Streaming not supported!' ) ;
237- done ( ) ;
238- } ) ) ;
233+ const src = gulp . src ( 'test/fixtures/test.css' , { buffer : false } ) ;
234+ const plugin = cleanCSS ( ) ;
235+ const out = src . pipe ( plugin ) ;
236+
237+ const checkErr = err => {
238+ expect ( err . message ) . to . equal ( 'Streaming not supported!' ) ;
239+ } ;
240+
241+ src . once ( 'error' , checkErr ) ;
242+ plugin . once ( 'error' , checkErr ) ;
243+
244+ out . once ( 'error' , ( err ) => {
245+ checkErr ( err ) ;
246+ src . destroy ( ) ;
247+ plugin . destroy ( ) ;
248+ done ( ) ;
249+ } ) ;
250+ out . resume ( ) ;
239251 } ) ;
240252
241253 it ( 'should handle malformed CSS' , done => {
242- let i = 0 ;
243254
244- gulp . src ( 'test/fixtures/malformed.css' )
245- . pipe ( cleanCSS ( ) )
246- . on ( 'error' , e => {
247- expect ( e ) . to . exist ;
248- done ( ) ;
249- } )
255+ const src = gulp . src ( 'test/fixtures/malformed.css' ) ;
256+ const plugin = cleanCSS ( ) ;
257+ const out = src . pipe ( plugin ) ;
258+
259+ const checkErr = err => {
260+ expect ( err ) . to . be . equal ( 'Ignoring local @import of "/some/fake/file" as resource is missing.' ) ;
261+ } ;
262+
263+ src . once ( 'error' , checkErr ) ;
264+ plugin . once ( 'error' , checkErr ) ;
265+
266+ out . once ( 'error' , ( err ) => {
267+ checkErr ( err ) ;
268+ src . destroy ( ) ;
269+ plugin . destroy ( ) ;
270+ done ( ) ;
271+ } ) ;
272+ out . resume ( ) ;
250273 } ) ;
251274
252275 it ( 'should not process empty directories or files' , done => {
0 commit comments