Skip to content

Commit

Permalink
chore: #365 - Add test for renaming Identifier to a ThisKeyword.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jul 16, 2018
1 parent 4a7b1e2 commit 03c1ebe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/tests/compiler/common/identifierTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ describe(nameof(Identifier), () => {
firstChild.getNameNode().rename("newFunction");
expect(sourceFile.getFullText()).to.equal(text.replace(/myFunction/g, "newFunction"));
});

it("should rename an identifier to a ThisKeyword", () => {
const text = "const that = this; that.test;";
const { sourceFile } = getInfoFromText(text);
const thatIdentifier = sourceFile.getFirstDescendantOrThrow(d => d.getKind() === SyntaxKind.Identifier && d.getText() === "that") as Identifier;
thatIdentifier.rename("this");
expect(thatIdentifier.wasForgotten()).to.be.true;
expect(sourceFile.getFullText()).to.equal("const this = this; this.test;");
});
});

describe(nameof<Identifier>(n => n.getDefinitions), () => {
Expand Down

0 comments on commit 03c1ebe

Please sign in to comment.