Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add a test case for unusual charsets #130

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions test/snapshots/transform.test.js.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ exports[`should perform transformation with source maps no filename 2`] = `
"{\\"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\\"}"
`;

exports[`should perform transformation with source maps with uncommon chars 1`] = `
"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"
`;

exports[`should perform transformation with source maps with uncommon chars 2`] = `
"{\\"version\\":3,\\"sources\\":[\\"dir%20with $unusual\\\\\\"chars?'åß∂ƒ©∆¬…\`.cts\\"],\\"names\\":[],\\"mappings\\":\\"AACI,IAAA,AAAK,6BAAA;;;WAAA;EAAA;AAKL\\"}"
`;

exports[`should perform transformation without source maps 1`] = `
"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"
`;
Expand Down
20 changes: 20 additions & 0 deletions test/transform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,26 @@ test("should perform transformation with source maps", (t) => {
assert.strictEqual(result, 7);
});

test("should perform transformation with source maps with uncommon chars", (t) => {
const tsCode = `
enum Foo {
Bar = 7,
Baz = 2,
}

output = Foo.Bar`;
const { code, map } = transformSync(tsCode, {
mode: "transform",
sourceMap: true,
filename: "dir%20with $unusual\"chars?'åß∂ƒ©∆¬…`.cts",
});

t.assert.snapshot(code);
t.assert.snapshot(map);
const result = vm.runInContext(code, vm.createContext());
assert.strictEqual(result, 7);
});

test("should perform transformation with source maps no filename", (t) => {
const tsCode = `
enum Foo {
Expand Down
Loading