Skip to content

Commit

Permalink
fix: stripe type with class modifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
himself65 committed Aug 9, 2024
1 parent 4ffa2cd commit a223e4e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,27 @@ test("should handle User type and isAdult function", (t) => {
t.assert.snapshot(code);
});

test("should handle class modifiers", (t) => {
const inputCode = `
class PrivateConstructor {
private constructor() {}
public a() {}
protected b() {}
static create() {
return new PrivateConstructor()
}
}
const ins = PrivateConstructor.create()
console.log(ins)
`;
const { code } = transformSync(inputCode);
t.assert.snapshot(code);
assert.strictEqual(code.includes("private"), false);
assert.strictEqual(code.includes("protected"), false);
assert.strictEqual(code.includes("public"), false);
});

test("should handle empty source code", (t) => {
assert.strictEqual(transformSync().code, "");
assert.throws(() => transformSync({}).code);
Expand Down
4 changes: 4 additions & 0 deletions test/snapshots/index.test.js.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ exports[`should handle User type and isAdult function 1`] = `
"\\n \\n \\n \\n \\n\\n function isAdult(user ) {\\n return user.age >= 18;\\n }\\n "
`;

exports[`should handle class modifiers 1`] = `
"\\n\\t\\tclass PrivateConstructor {\\n\\t\\t private constructor() {}\\n\\t\\t a() {}\\n\\t\\t b() {}\\n\\t\\t static create() {\\n\\t\\t return new PrivateConstructor()\\n\\t\\t }\\n\\t\\t}\\n\\n\\t\\tconst ins = PrivateConstructor.create()\\n\\t\\tconsole.log(ins)\\n\\t"
`;

exports[`should perform type stripping 1`] = `
"const foo = 'bar';"
`;
Expand Down

0 comments on commit a223e4e

Please sign in to comment.