@@ -27,7 +27,7 @@ describe('watcher', () => {
27
27
} ) ;
28
28
29
29
it ( 'should trigger the callback for files that are not ignored' , ( done ) => {
30
- watcher = new Watcher ( realpathSync ( temp . tempDir ) ) ;
30
+ watcher = new Watcher ( temp . tempDir ) ;
31
31
watcher . watch ( ( error , paths ) => {
32
32
expect ( paths ) . toMatchInlineSnapshot ( `
33
33
[
@@ -48,7 +48,7 @@ describe('watcher', () => {
48
48
} ) ;
49
49
50
50
it ( 'should trigger the callback when files are updated' , ( done ) => {
51
- watcher = new Watcher ( realpathSync ( temp . tempDir ) ) ;
51
+ watcher = new Watcher ( temp . tempDir ) ;
52
52
53
53
watcher . watch ( ( err , paths ) => {
54
54
expect ( paths ) . toMatchInlineSnapshot ( `
@@ -62,26 +62,30 @@ describe('watcher', () => {
62
62
done ( ) ;
63
63
} ) ;
64
64
65
- wait ( ) . then ( ( ) => {
65
+ wait ( 1000 ) . then ( ( ) => {
66
66
// nxignored file should not trigger a callback
67
67
temp . appendFile ( 'app2/main.js' , 'update' ) ;
68
68
temp . appendFile ( 'app1/main.js' , 'update' ) ;
69
69
} ) ;
70
70
} ) ;
71
71
72
72
it ( 'should watch file renames' , ( done ) => {
73
- watcher = new Watcher ( realpathSync ( temp . tempDir ) ) ;
73
+ watcher = new Watcher ( temp . tempDir ) ;
74
74
75
75
watcher . watch ( ( err , paths ) => {
76
76
expect ( paths . length ) . toBe ( 2 ) ;
77
- expect ( paths . find ( ( p ) => p . type === 'update' ) ) . toMatchObject ( {
78
- path : 'app1/rename.js' ,
79
- type : 'update' ,
80
- } ) ;
81
- expect ( paths . find ( ( p ) => p . type === 'delete' ) ) . toMatchObject ( {
82
- path : 'app1/main.js' ,
83
- type : 'delete' ,
84
- } ) ;
77
+ expect ( paths . find ( ( p ) => p . type === 'create' ) ) . toMatchInlineSnapshot ( `
78
+ {
79
+ "path": "app1/rename.js",
80
+ "type": "create",
81
+ }
82
+ ` ) ;
83
+ expect ( paths . find ( ( p ) => p . type === 'delete' ) ) . toMatchInlineSnapshot ( `
84
+ {
85
+ "path": "app1/main.js",
86
+ "type": "delete",
87
+ }
88
+ ` ) ;
85
89
done ( ) ;
86
90
} ) ;
87
91
@@ -91,7 +95,7 @@ describe('watcher', () => {
91
95
} ) ;
92
96
93
97
it ( 'should trigger on deletes' , ( done ) => {
94
- watcher = new Watcher ( realpathSync ( temp . tempDir ) ) ;
98
+ watcher = new Watcher ( temp . tempDir ) ;
95
99
96
100
watcher . watch ( ( err , paths ) => {
97
101
expect ( paths ) . toMatchInlineSnapshot ( `
@@ -111,7 +115,7 @@ describe('watcher', () => {
111
115
} ) ;
112
116
113
117
it ( 'should ignore nested gitignores' , ( done ) => {
114
- watcher = new Watcher ( realpathSync ( temp . tempDir ) ) ;
118
+ watcher = new Watcher ( temp . tempDir ) ;
115
119
116
120
watcher . watch ( ( err , paths ) => {
117
121
expect ( paths ) . toMatchInlineSnapshot ( `
@@ -133,10 +137,10 @@ describe('watcher', () => {
133
137
} ) ;
134
138
} ) ;
135
139
136
- function wait ( ) {
140
+ function wait ( timeout = 500 ) {
137
141
return new Promise < void > ( ( res ) => {
138
142
setTimeout ( ( ) => {
139
143
res ( ) ;
140
- } , 500 ) ;
144
+ } , timeout ) ;
141
145
} ) ;
142
146
}
0 commit comments