9
9
10
10
const ignoredFiles = require ( '../ignoredFiles' ) ;
11
11
12
+ const anymatch = require ( 'anymatch' ) ;
13
+
12
14
describe ( 'ignore watch files regex' , ( ) => {
13
15
it ( 'normal file' , ( ) => {
14
16
const appSrc = '/root/src/' ;
15
- const isIgnored = ignoredFiles ( appSrc ) . test ( '/foo' ) ;
16
- const isIgnoredInSrc = ignoredFiles ( appSrc ) . test ( '/root/src/foo' ) ;
17
+ const isIgnored = anymatch ( ignoredFiles ( appSrc ) , '/foo' ) ;
18
+ const isIgnoredInSrc = anymatch ( ignoredFiles ( appSrc ) , '/root/src/foo' ) ;
17
19
18
20
expect ( isIgnored ) . toBe ( false ) ;
19
21
expect ( isIgnoredInSrc ) . toBe ( false ) ;
20
22
} ) ;
21
23
22
24
it ( 'node modules' , ( ) => {
23
25
const appSrc = '/root/src/' ;
24
- const isIgnored = ignoredFiles ( appSrc ) . test ( '/root/node_modules/foo' ) ;
26
+ const isIgnored = anymatch ( ignoredFiles ( appSrc ) , '/root/node_modules/foo' ) ;
25
27
26
28
expect ( isIgnored ) . toBe ( true ) ;
27
29
} ) ;
28
30
29
31
it ( 'node modules inside source directory' , ( ) => {
30
32
const appSrc = '/root/src/' ;
31
- const isIgnored = ignoredFiles ( appSrc ) . test ( '/root/src/node_modules/foo' ) ;
32
- const isIgnoredMoreThanOneLevel = ignoredFiles ( appSrc ) . test (
33
+ const isIgnored = anymatch (
34
+ ignoredFiles ( appSrc ) ,
35
+ '/root/src/node_modules/foo'
36
+ ) ;
37
+ const isIgnoredMoreThanOneLevel = anymatch (
38
+ ignoredFiles ( appSrc ) ,
33
39
'/root/src/bar/node_modules/foo'
34
40
) ;
35
41
@@ -39,7 +45,8 @@ describe('ignore watch files regex', () => {
39
45
40
46
it ( 'path contains source directory' , ( ) => {
41
47
const appSrc = '/root/src/' ;
42
- const isIgnored = ignoredFiles ( appSrc ) . test (
48
+ const isIgnored = anymatch (
49
+ ignoredFiles ( appSrc ) ,
43
50
'/bar/root/src/node_modules/foo'
44
51
) ;
45
52
@@ -48,7 +55,10 @@ describe('ignore watch files regex', () => {
48
55
49
56
it ( 'path starts with source directory' , ( ) => {
50
57
const appSrc = '/root/src/' ;
51
- const isIgnored = ignoredFiles ( appSrc ) . test ( '/root/src2/node_modules/foo' ) ;
58
+ const isIgnored = anymatch (
59
+ ignoredFiles ( appSrc ) ,
60
+ '/root/src2/node_modules/foo'
61
+ ) ;
52
62
53
63
expect ( isIgnored ) . toBe ( true ) ;
54
64
} ) ;
0 commit comments