@@ -165,6 +165,90 @@ describe("CachedInputFileSystem OperationMergerBackend ('lstat' and 'lstatSync')
165
165
} ) ;
166
166
} ) ;
167
167
168
+ describe ( "CachedInputFileSystem OperationMergerBackend ('realpath' and 'realpathSync')" , ( ) => {
169
+ let fs ;
170
+
171
+ beforeEach ( ( ) => {
172
+ fs = new CachedInputFileSystem (
173
+ {
174
+ realpath : function ( path , options , callback ) {
175
+ if ( ! callback ) {
176
+ callback = options ;
177
+ options = undefined ;
178
+ }
179
+ setTimeout (
180
+ ( ) =>
181
+ callback ( null , {
182
+ path,
183
+ options
184
+ } ) ,
185
+ 100
186
+ ) ;
187
+ } ,
188
+ realpathSync : function ( path , options ) {
189
+ return {
190
+ path,
191
+ options
192
+ } ;
193
+ }
194
+ } ,
195
+ 0
196
+ ) ;
197
+ } ) ;
198
+ afterEach ( ( ) => {
199
+ fs . purge ( ) ;
200
+ } ) ;
201
+
202
+ it ( "should join accesses" , function ( done ) {
203
+ fs . realpath ( "a" , function ( err , result ) {
204
+ expect ( result ) . toBeDefined ( ) ;
205
+ result . a = true ;
206
+ } ) ;
207
+ fs . realpath ( "a" , function ( err , result ) {
208
+ expect ( result ) . toBeDefined ( ) ;
209
+ expect ( result . a ) . toBeDefined ( ) ;
210
+ done ( ) ;
211
+ } ) ;
212
+ } ) ;
213
+
214
+ it ( "should not join accesses with options" , function ( done ) {
215
+ fs . realpath ( "a" , function ( err , result ) {
216
+ expect ( result ) . toBeDefined ( ) ;
217
+
218
+ result . a = true ;
219
+
220
+ expect ( result ) . toBeDefined ( ) ;
221
+ expect ( result . path ) . toEqual ( "a" ) ;
222
+ expect ( result . options ) . toBeUndefined ( ) ;
223
+ } ) ;
224
+ fs . realpath ( "a" , { options : true } , function ( err , result ) {
225
+ expect ( result ) . toBeDefined ( ) ;
226
+ expect ( result . a ) . toBeUndefined ( ) ;
227
+ expect ( result . path ) . toEqual ( "a" ) ;
228
+ expect ( result . options ) . toMatchObject ( { options : true } ) ;
229
+ done ( ) ;
230
+ } ) ;
231
+ } ) ;
232
+
233
+ it ( "should not cache accesses" , function ( done ) {
234
+ fs . realpath ( "a" , function ( err , result ) {
235
+ result . a = true ;
236
+ fs . realpath ( "a" , function ( err , result ) {
237
+ expect ( result . a ) . toBeUndefined ( ) ;
238
+ done ( ) ;
239
+ } ) ;
240
+ } ) ;
241
+ } ) ;
242
+
243
+ it ( "should not cache sync accesses" , ( ) => {
244
+ const result = fs . realpathSync ( "a" ) ;
245
+ result . a = true ;
246
+ const result2 = fs . realpathSync ( "a" ) ;
247
+
248
+ expect ( result2 . a ) . toBeUndefined ( ) ;
249
+ } ) ;
250
+ } ) ;
251
+
168
252
describe ( "CachedInputFileSystem CacheBackend" , ( ) => {
169
253
let fs ;
170
254
0 commit comments