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 4eca63a commit e31ab3a
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 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,24 @@ test("should handle invalid identifiers", async () => {
const result = await visitAllIdentifiers(code, async () => "this.kLength");
assert.equal(result, "const thisKLength = 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 e31ab3a

Please sign in to comment.