Skip to content

Commit

Permalink
Add more invalid identifier tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jehna committed Oct 6, 2024
1 parent b7e5d63 commit a317fd3
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/plugins/local-llm-rename/visit-all-identifiers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,30 @@ test("should handle invalid identifiers", async () => {
const result = await visitAllIdentifiers(code, async () => "this.kLength");
assert.equal(result, "const thisKLength = 1;");
});

test("should handle space in identifier name (happens for some reason though it shouldn't)", async () => {
const code = `const a = 1`;
const result = await visitAllIdentifiers(code, async () => "foo bar");
assert.equal(result, "const fooBar = 1;");
});

test("should handle reserved identifiers", async () => {
const code = `const a = 1`;
const result = await visitAllIdentifiers(code, async () => "static");
assert.equal(result, "const _static = 1;");
});

test("should handle multiple identifiers named the same", async () => {
const code = `
const a = 1;
const b = 1;
`.trim();
const result = await visitAllIdentifiers(code, async () => "foo");
assert.equal(
result,
`
const foo = 1;
const _foo = 1;
`.trim()
);
});

0 comments on commit a317fd3

Please sign in to comment.