Skip to content

Commit 3857f1b

Browse files
committed
test: add a test case for unusual charsets
1 parent 74efd93 commit 3857f1b

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

test/snapshots/transform.test.js.snapshot

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ exports[`should perform transformation with source maps no filename 2`] = `
3434
"{\\"version\\":3,\\"sources\\":[\\"<anon>\\"],\\"sourcesContent\\":[\\"\\\\n enum Foo {\\\\n Bar = 7,\\\\n Baz = 2,\\\\n }\\\\n output = Foo.Bar\\"],\\"names\\":[],\\"mappings\\":\\"AACI,IAAA,AAAK,6BAAA;;;WAAA;EAAA;AAIL\\"}"
3535
`;
3636

37+
exports[`should perform transformation with source maps with uncommon chars 1`] = `
38+
"var Foo = /*#__PURE__*/ function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n return Foo;\\n}(Foo || {});\\noutput = 7;\\n"
39+
`;
40+
41+
exports[`should perform transformation with source maps with uncommon chars 2`] = `
42+
"{\\"version\\":3,\\"sources\\":[\\"dir%20with $unusual\\\\\\"chars?'åß∂ƒ©∆¬…\`.cts\\"],\\"names\\":[],\\"mappings\\":\\"AACI,IAAA,AAAK,6BAAA;;;WAAA;EAAA;AAKL\\"}"
43+
`;
44+
3745
exports[`should perform transformation without source maps 1`] = `
3846
"var Foo = /*#__PURE__*/ function(Foo) {\\n Foo[Foo[\\"Bar\\"] = 7] = \\"Bar\\";\\n Foo[Foo[\\"Baz\\"] = 2] = \\"Baz\\";\\n return Foo;\\n}(Foo || {});\\noutput = 7;\\n"
3947
`;

test/transform.test.js

+20
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,26 @@ test("should perform transformation with source maps", (t) => {
7070
assert.strictEqual(result, 7);
7171
});
7272

73+
test("should perform transformation with source maps with uncommon chars", (t) => {
74+
const tsCode = `
75+
enum Foo {
76+
Bar = 7,
77+
Baz = 2,
78+
}
79+
80+
output = Foo.Bar`;
81+
const { code, map } = transformSync(tsCode, {
82+
mode: "transform",
83+
sourceMap: true,
84+
filename: "dir%20with\ \$unusual\"chars\?\'åß∂ƒ©∆¬…\`.cts",
85+
});
86+
87+
t.assert.snapshot(code);
88+
t.assert.snapshot(map);
89+
const result = vm.runInContext(code, vm.createContext());
90+
assert.strictEqual(result, 7);
91+
});
92+
7393
test("should perform transformation with source maps no filename", (t) => {
7494
const tsCode = `
7595
enum Foo {

0 commit comments

Comments
 (0)