Skip to content

Commit 3a5c6fd

Browse files
committed
add extra tests
1 parent f125552 commit 3a5c6fd

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

packages/tests-unit/tests/utils/regex.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,20 @@ describe("getCrossPlatformPathRegex", () => {
2121
String.raw`\^\(\[123\]\+\|\[123\]\{1,3\}\)\*\\\?\$`,
2222
);
2323
});
24+
25+
it("should return cross-platform paths with escaped special characters", () => {
26+
[
27+
["core/resolve.js", String.raw`core(?:\/|\\)resolve\.js`],
28+
["./middleware.mjs", String.raw`\.(?:\/|\\)middleware\.mjs`],
29+
].forEach(([input, output]) =>
30+
expect(getCrossPlatformPathRegex(input).source).toEqual(output),
31+
);
32+
});
33+
34+
it("should return cross-platform paths without escaping special characters", () => {
35+
const regex = getCrossPlatformPathRegex("\\./middleware\\.(mjs|cjs)", {
36+
escape: false,
37+
});
38+
expect(regex.source).toEqual(String.raw`\.(?:\/|\\)middleware\.(mjs|cjs)`);
39+
});
2440
});

0 commit comments

Comments
 (0)