-
Notifications
You must be signed in to change notification settings - Fork 599
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
revert broken feedback Updated comment Added tests for HasteFS Update HasteFS-test.js Add contextModuleTemplates tests fixup types Update index.js Drop getTransformFn drop unused Update types.flow.js Added more tests inputPath -> from Test require.context fixup
- Loading branch information
Showing
21 changed files
with
625 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
* @format | ||
*/ | ||
|
||
import HasteFS from '../HasteFS'; | ||
|
||
describe('matchFilesWithContext', () => { | ||
it(`matches files against context`, () => { | ||
const hfs = new HasteFS({ | ||
rootDir: '/', | ||
files: new Map([]), | ||
}); | ||
|
||
// $FlowFixMe: mocking files | ||
hfs.getAbsoluteFileIterator = function () { | ||
return ['/foo/another.js', '/bar.js']; | ||
}; | ||
|
||
// Test non-recursive skipping deep paths | ||
expect( | ||
hfs.matchFilesWithContext('/', { | ||
filter: new RegExp( | ||
// Test starting with `./` since this is mandatory for parity with Webpack. | ||
/^\.\/.*/, | ||
), | ||
recursive: false, | ||
}), | ||
).toEqual(['/bar.js']); | ||
|
||
// Test inner directory | ||
expect( | ||
hfs.matchFilesWithContext('/foo', { | ||
filter: new RegExp(/.*/), | ||
recursive: true, | ||
}), | ||
).toEqual(['/foo/another.js']); | ||
|
||
// Test recursive | ||
expect( | ||
hfs.matchFilesWithContext('/', { | ||
filter: new RegExp(/.*/), | ||
recursive: true, | ||
}), | ||
).toEqual(['/foo/another.js', '/bar.js']); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.