@@ -53,25 +53,25 @@ test('Compile css file with sourcemap (options.map)', async t => {
5353} ) ;
5454
5555test ( 'Compile scss file with sourcemap (options.sourceMap) and custom preprocessor' , async t => {
56- const fixture = 'test/fixtures/basic.css' ;
56+ const fixture = 'test/fixtures/basic.custom. css' ;
5757 const options = { plugins : [ atImport , mixins , simpleVars , cssnano ] , sourceMap : true } ;
5858 const { preprocessor, debug} = mockPreprocessor ( { options} ) ;
5959 const file = { originalPath : fixture } ;
6060
6161 t . is ( ( await preprocessor ( await readFile ( fixture ) , file ) ) . toString ( ) , await compile ( fixture , options ) ) ;
6262 t . true ( debug . firstCall . calledWith ( match ( 'Processing' ) , fixture ) ) ;
63- t . is ( path . resolve ( file . path ) , path . resolve ( 'test/fixtures/basic.css' ) ) ;
63+ t . is ( path . resolve ( file . path ) , path . resolve ( 'test/fixtures/basic.custom. css' ) ) ;
6464} ) ;
6565
6666test ( 'Compile scss file with sourcemap (options.map) and custom preprocessor' , async t => {
67- const fixture = 'test/fixtures/basic.css' ;
67+ const fixture = 'test/fixtures/basic.custom. css' ;
6868 const options = { plugins : [ atImport , mixins , simpleVars , cssnano ] , map : true } ;
6969 const { preprocessor, debug} = mockPreprocessor ( { options} ) ;
7070 const file = { originalPath : fixture } ;
7171
7272 t . is ( ( await preprocessor ( await readFile ( fixture ) , file ) ) . toString ( ) , await compile ( fixture , options ) ) ;
7373 t . true ( debug . firstCall . calledWith ( match ( 'Processing' ) , fixture ) ) ;
74- t . is ( path . resolve ( file . path ) , path . resolve ( 'test/fixtures/basic.css' ) ) ;
74+ t . is ( path . resolve ( file . path ) , path . resolve ( 'test/fixtures/basic.custom. css' ) ) ;
7575} ) ;
7676
7777test ( 'Compile scss file with partial import' , async t => {
@@ -121,7 +121,7 @@ test('Compile css file with custom transformPath', async t => {
121121} ) ;
122122
123123test ( 'Compile css file with custom transformPath and custom preprocessor' , async t => {
124- const fixture = 'test/fixtures/basic.txt' ;
124+ const fixture = 'test/fixtures/basic.custom. txt' ;
125125 const options = { plugins : [ atImport , mixins , simpleVars , cssnano ] } ;
126126 const transformPath = spy ( filePath => filePath . replace ( / \. ( t x t ) $ / , '.css' ) . replace ( 'fixtures/' , '' ) ) ;
127127 const { preprocessor, debug} = mockPreprocessor ( { transformPath, options} ) ;
@@ -130,7 +130,7 @@ test('Compile css file with custom transformPath and custom preprocessor', async
130130 t . is ( ( await preprocessor ( await readFile ( fixture ) , file ) ) . toString ( ) , await compile ( fixture , options ) ) ;
131131 t . true ( debug . firstCall . calledWith ( match ( 'Processing' ) , fixture ) ) ;
132132 t . true ( transformPath . calledOnce ) ;
133- t . is ( path . resolve ( file . path ) , path . resolve ( 'test/basic.css' ) ) ;
133+ t . is ( path . resolve ( file . path ) , path . resolve ( 'test/basic.custom. css' ) ) ;
134134} ) ;
135135
136136test ( 'Log error on invalid css file' , async t => {
@@ -305,6 +305,46 @@ test('Do not remove dependency from watcher when unreferenced, if another file s
305305 t . true ( debug . calledTwice ) ;
306306} ) ;
307307
308+ test ( 'Do not remove dependency from watcher when different files have differents childs' , async t => {
309+ const dir = path . resolve ( tmp ( ) ) ;
310+ const fixture = path . join ( dir , 'with-partial.css' ) ;
311+ const otherFixture = path . join ( dir , 'other-with-partial.css' ) ;
312+ const includePath = path . join ( dir , 'partials' ) ;
313+ const partial = path . join ( includePath , 'partial.css' ) ;
314+ const partialAlt = path . join ( includePath , 'partial-alt.css' ) ;
315+ const subPartial = path . join ( includePath , 'sub-partial.css' ) ;
316+ const options = { plugins : [ atImport ( { path : [ includePath ] } ) , mixins , simpleVars , cssnano ] } ;
317+ const { preprocessor, add, debug, unwatch} = mockPreprocessor (
318+ { } ,
319+ {
320+ autoWatch : true ,
321+ files : [ { pattern : fixture , watched : true } , { pattern : otherFixture , watched : true } ] ,
322+ postcssPreprocessor : { options} ,
323+ }
324+ ) ;
325+ const file = { originalPath : fixture } ;
326+ const otherFile = { originalPath : otherFixture } ;
327+
328+ await Promise . all ( [
329+ copy ( 'test/fixtures/partials/partial.css' , partial ) ,
330+ copy ( 'test/fixtures/partials/partial.css' , partialAlt ) ,
331+ copy ( 'test/fixtures/partials/sub-partial.css' , subPartial ) ,
332+ copy ( 'test/fixtures/with-partial.css' , fixture ) ,
333+ copy ( 'test/fixtures/with-partial.css' , otherFixture ) ,
334+ ] ) ;
335+ await outputFile (
336+ fixture ,
337+ ( await readFile ( fixture ) ) . toString ( ) . replace ( `@import 'partial';` , `@import 'partial-alt';` )
338+ ) ;
339+ await preprocessor ( await readFile ( fixture ) , file ) ;
340+ add . reset ( ) ;
341+ debug . reset ( ) ;
342+ await preprocessor ( await readFile ( otherFixture ) , otherFile ) ;
343+ t . true ( add . calledOnce ) ;
344+ t . true ( unwatch . notCalled ) ;
345+ t . true ( debug . calledTwice ) ;
346+ } ) ;
347+
308348test ( 'Call refreshFiles when dependency is modified' , async t => {
309349 const dir = path . resolve ( tmp ( ) ) ;
310350 const fixture = path . join ( dir , 'with-partial.css' ) ;
@@ -366,7 +406,6 @@ test('Call refreshFiles when dependency is deleted and added', async t => {
366406 info . reset ( ) ;
367407 refreshFiles . reset ( ) ;
368408 await t . throws ( preprocessor ( await readFile ( fixture ) , file ) , Error ) ;
369-
370409 const cpy = waitFor ( watcher , 'add' ) ;
371410
372411 await copy ( 'test/fixtures/partials/partial.css' , partial ) ;
0 commit comments