@@ -17,15 +17,16 @@ function fixture(...args) {
1717}
1818
1919test ( 'ignores relativeness in patterns' , t => {
20- const { filePatterns} = globs . normalizeGlobs ( { files : [ './foo.js' , '!./bar' ] , extensions : [ 'js' ] } ) ;
20+ const { filePatterns} = globs . normalizeGlobs ( { files : [ './foo.js' , '!./bar' ] , extensions : [ 'js' ] , providers : [ ] } ) ;
2121 t . deepEqual ( filePatterns , [ 'foo.js' , '!bar' ] ) ;
2222 t . end ( ) ;
2323} ) ;
2424
2525test ( 'isTest with defaults' , t => {
2626 const options = {
2727 ...globs . normalizeGlobs ( {
28- extensions : [ 'js' ]
28+ extensions : [ 'js' ] ,
29+ providers : [ ]
2930 } ) ,
3031 cwd : fixture ( )
3132 } ;
@@ -99,7 +100,8 @@ test('isTest with patterns', t => {
99100 const options = {
100101 ...globs . normalizeGlobs ( {
101102 files : [ '**/foo*.js' , '**/foo*/**/*.js' , '!**/fixtures' , '!**/helpers' ] ,
102- extensions : [ 'js' ]
103+ extensions : [ 'js' ] ,
104+ providers : [ ]
103105 } ) ,
104106 cwd : fixture ( )
105107 } ;
@@ -133,7 +135,8 @@ test('isTest (pattern starts with directory)', t => {
133135 const options = {
134136 ...globs . normalizeGlobs ( {
135137 files : [ 'bar/**/*' ] ,
136- extensions : [ 'js' ]
138+ extensions : [ 'js' ] ,
139+ providers : [ ]
137140 } ) ,
138141 cwd : fixture ( )
139142 } ;
@@ -163,9 +166,35 @@ test('isTest (pattern starts with directory)', t => {
163166 t . end ( ) ;
164167} ) ;
165168
169+ test ( 'isTest after provider modifications' , t => {
170+ const options = {
171+ ...globs . normalizeGlobs ( {
172+ extensions : [ 'js' ] ,
173+ providers : [ {
174+ level : 2 ,
175+ main : {
176+ updateGlobs ( { filePatterns, ignoredByWatcherPatterns} ) {
177+ t . true ( filePatterns . length > 0 ) ;
178+ t . true ( ignoredByWatcherPatterns . length > 0 ) ;
179+ return {
180+ filePatterns : [ 'foo.js' ] ,
181+ ignoredByWatcherPatterns
182+ } ;
183+ }
184+ }
185+ } ]
186+ } ) ,
187+ cwd : fixture ( )
188+ } ;
189+
190+ t . true ( globs . classify ( fixture ( 'foo.js' ) , options ) . isTest ) ;
191+ t . false ( globs . classify ( fixture ( 'bar.js' ) , options ) . isTest ) ;
192+ t . end ( ) ;
193+ } ) ;
194+
166195test ( 'isIgnoredByWatcher with defaults' , t => {
167196 const options = {
168- ...globs . normalizeGlobs ( { extensions : [ 'js' ] } ) ,
197+ ...globs . normalizeGlobs ( { extensions : [ 'js' ] , providers : [ ] } ) ,
169198 cwd : fixture ( )
170199 } ;
171200
@@ -203,7 +232,8 @@ test('isIgnoredByWatcher with patterns', t => {
203232 ...globs . normalizeGlobs ( {
204233 files : [ '**/foo*' ] ,
205234 ignoredByWatcher : [ '**/bar*' ] ,
206- extensions : [ 'js' ]
235+ extensions : [ 'js' ] ,
236+ providers : [ ]
207237 } ) ,
208238 cwd : fixture ( )
209239 } ;
@@ -219,7 +249,8 @@ test('isIgnoredByWatcher (pattern starts with directory)', t => {
219249 ...globs . normalizeGlobs ( {
220250 files : [ '**/foo*' ] ,
221251 ignoredByWatcher : [ 'foo/**/*' ] ,
222- extensions : [ 'js' ]
252+ extensions : [ 'js' ] ,
253+ providers : [ ]
223254 } ) ,
224255 cwd : fixture ( )
225256 } ;
@@ -230,6 +261,32 @@ test('isIgnoredByWatcher (pattern starts with directory)', t => {
230261 t . end ( ) ;
231262} ) ;
232263
264+ test ( 'isIgnoredByWatcher after provider modifications' , t => {
265+ const options = {
266+ ...globs . normalizeGlobs ( {
267+ extensions : [ 'js' ] ,
268+ providers : [ {
269+ level : 2 ,
270+ main : {
271+ updateGlobs ( { filePatterns, ignoredByWatcherPatterns} ) {
272+ t . true ( filePatterns . length > 0 ) ;
273+ t . true ( ignoredByWatcherPatterns . length > 0 ) ;
274+ return {
275+ filePatterns,
276+ ignoredByWatcherPatterns : [ 'foo.js' ]
277+ } ;
278+ }
279+ }
280+ } ]
281+ } ) ,
282+ cwd : fixture ( )
283+ } ;
284+
285+ t . true ( globs . classify ( fixture ( 'foo.js' ) , options ) . isIgnoredByWatcher ) ;
286+ t . false ( globs . classify ( fixture ( 'bar.js' ) , options ) . isIgnoredByWatcher ) ;
287+ t . end ( ) ;
288+ } ) ;
289+
233290test ( 'findFiles finds non-ignored files (just .js)' , async t => {
234291 const fixtureDir = fixture ( 'default-patterns' ) ;
235292 process . chdir ( fixtureDir ) ;
@@ -251,7 +308,7 @@ test('findFiles finds non-ignored files (just .js)', async t => {
251308
252309 const actual = await globs . findFiles ( {
253310 cwd : fixtureDir ,
254- ...globs . normalizeGlobs ( { files : [ '!**/fixtures/*.*' , '!**/helpers/*.*' ] , extensions : [ 'js' ] } )
311+ ...globs . normalizeGlobs ( { files : [ '!**/fixtures/*.*' , '!**/helpers/*.*' ] , extensions : [ 'js' ] , providers : [ ] } )
255312 } ) ;
256313 actual . sort ( ) ;
257314 t . deepEqual ( actual , expected ) ;
@@ -270,7 +327,7 @@ test('findFiles finds non-ignored files (.js, .jsx)', async t => {
270327
271328 const actual = await globs . findFiles ( {
272329 cwd : fixtureDir ,
273- ...globs . normalizeGlobs ( { files : [ '!**/fixtures/*' , '!**/helpers/*' ] , extensions : [ 'js' , 'jsx' ] } )
330+ ...globs . normalizeGlobs ( { files : [ '!**/fixtures/*' , '!**/helpers/*' ] , extensions : [ 'js' , 'jsx' ] , providers : [ ] } )
274331 } ) ;
275332 actual . sort ( ) ;
276333 t . deepEqual ( actual , expected ) ;
0 commit comments