Skip to content
This repository was archived by the owner on Jun 26, 2025. It is now read-only.

Commit f41e942

Browse files
committed
Add tests for win32 paths
1 parent 799e005 commit f41e942

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

__tests__/regexps.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ describe('generateIncludes', () => {
3838
expect(anymatch(includes, '../../node_modules/something-else/test.js')).toBe(false);
3939
expect(anymatch(includes, 'node_modules/and-yet-another/test.js')).toBe(false);
4040
});
41+
42+
test('should handle win32 path delimiters well', () => {
43+
const module = '@scoped/something';
44+
const anotherModule = '@scoped\\something';
45+
46+
expect(anymatch(includes, `C:\\test\\node_modules\\${module}\\sub\\test.js`)).toBe(true);
47+
expect(anymatch(includes, `C:\\test\\node_modules\\${anotherModule}\\sub\\test.js`)).toBe(true);
48+
expect(anymatch(includes, `C:\\test\\node_modules\\unused\\sub\\test.js`)).toBe(false);
49+
});
4150
});
4251

4352
describe('generateExcludes', () => {
@@ -67,6 +76,15 @@ describe('generateExcludes', () => {
6776
expect(anymatch(excludes, '../../node_modules/something-else')).toBe(true);
6877
expect(anymatch(excludes, 'node_modules/and-yet-another')).toBe(true);
6978
});
79+
80+
test('should handle win32 path delimiters well', () => {
81+
const module = '@scoped/something';
82+
const anotherModule = '@scoped\\something';
83+
84+
expect(anymatch(excludes, `C:\\test\\node_modules\\${module}\\sub\\test.js`)).toBe(false);
85+
expect(anymatch(excludes, `C:\\test\\node_modules\\${anotherModule}\\sub\\test.js`)).toBe(false);
86+
expect(anymatch(excludes, `C:\\test\\node_modules\\unused\\sub\\test.js`)).toBe(true);
87+
});
7088
});
7189

7290
describe('regexEqual', () => {

0 commit comments

Comments
 (0)