@@ -15,9 +15,15 @@ function d([str]) {
1515describe ( 'loader' , ( ) => {
1616 function testLoader ( fileName , callback , query , version = 2 ) {
1717 return done => {
18- function cb ( ) {
18+ const addedDependencies = new Set ( ) ;
19+
20+ function cb ( ...args ) {
21+ while ( args . length < 4 ) {
22+ args . push ( undefined ) ;
23+ }
24+ args . push ( addedDependencies ) ;
1925 try {
20- callback ( ...[ ] . slice . call ( arguments ) ) ;
26+ callback ( ...args ) ;
2127 } catch ( err ) {
2228 expect ( callbackSpy ) . to . have . been . called ;
2329 return done ( err ) ;
@@ -32,10 +38,13 @@ describe('loader', () => {
3238
3339 const callbackSpy = spy ( cb ) ;
3440
41+ const dependencySpy = spy ( function ( p ) { addedDependencies . add ( p ) ; } ) ;
42+
3543 loader . call (
3644 {
3745 cacheable : cacheableSpy ,
3846 async : ( ) => callbackSpy ,
47+ addDependency : dependencySpy ,
3948 resourcePath : fileName ,
4049 version,
4150 query
@@ -45,6 +54,10 @@ describe('loader', () => {
4554 ) ;
4655
4756 expect ( cacheableSpy ) . to . have . been . called ;
57+
58+ for ( const call of dependencySpy . getCalls ( ) ) {
59+ expect ( call . firstArg ) . to . be . a ( 'string' ) ;
60+ }
4861 } ;
4962 }
5063
@@ -246,23 +259,18 @@ describe('loader', () => {
246259 } ) ;
247260
248261 it ( 'should not preprocess successfully' , done => {
249- const { warn } = console ;
250- const warnings = [ ] ;
251-
252- console . warn = msg => {
253- warnings . push ( msg ) ;
254- } ;
255-
256262 testLoader (
257263 'test/fixtures/style-valid.html' ,
258- ( err , code , map ) => {
264+ ( err , code , map , context , addedDependencies ) => {
259265 expect ( err ) . to . exist ;
260- console . warn = warn ;
266+ expect ( addedDependencies ) . to . include ( '/some/subresource.css' ) ;
261267 } ,
262268 {
263269 preprocess : {
264270 style : ( ) => {
265- throw new Error ( 'Error while preprocessing' ) ;
271+ const e = new Error ( 'Error while preprocessing' ) ;
272+ e . filename = '/some/subresource.css' ;
273+ throw e ;
266274 }
267275 }
268276 }
0 commit comments