Skip to content

Commit

Permalink
test: add tests for nativeClassProperties
Browse files Browse the repository at this point in the history
  • Loading branch information
marco-ippolito committed Aug 14, 2024
1 parent 4fef7c6 commit 80190fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test/snapshots/transform.test.js.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,7 @@ exports[`should transform TypeScript private class fields 1`] = `
exports[`should transform TypeScript type annotations and type guards 1`] = `
"function isString(value) {\\n return typeof value === 'string';\\n}\\nconst check = isString(\\"hello\\");\\noutput = check;\\n"
`;

exports[`test native class properties 1`] = `
"class Foo {\\n y;\\n x;\\n constructor(y = console.log(2)){\\n this.y = y;\\n this.x = console.log(1);\\n console.log(3);\\n }\\n}\\n"
`;
19 changes: 19 additions & 0 deletions test/transform.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,22 @@ test("should transform TypeScript namespaces with additional functionality", (t)
assert.ok(result.validator);
assert.strictEqual(result.isValid, true);
});

test("test native class properties", (t) => {
const inputCode = `
class Foo {
x = console.log(1)
constructor(public y = console.log(2)) {
console.log(3)
}
}`;
const { code } = transformSync(inputCode, {
mode: "transform",
sourceMap: true,
transform: {
verbatimModuleSyntax: true,
nativeClassProperties: true,
},
});
t.assert.snapshot(code);
});

0 comments on commit 80190fa

Please sign in to comment.