/
1198tests.ts
35 lines (31 loc) · 1.12 KB
/
1198tests.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { expect } from "chai";
import { Project } from "../../Project";
describe.only("tests for issue #1198", () => {
it("should not have issues when renaming private identifier", () => {
const project = new Project({ useInMemoryFileSystem: true });
const sourceFile = project.createSourceFile("mod.ts", `class Foo {
private one: string;
private two: string;
}`);
const classDecl = sourceFile.getClasses()[0];
for (const property of classDecl.getInstanceProperties()) {
const name = property.getName();
property.toggleModifier("private", false);
property.rename(`#${name}`);
}
expect(sourceFile.getText()).to.equal(`class Foo {
#one: string;
#two: string;
}`);
// now swap them back
for (const property of classDecl.getInstanceProperties()) {
const name = property.getName().replace(/^#/, "");
property.rename(`${name}`);
property.toggleModifier("private", true);
}
expect(sourceFile.getText()).to.equal(`class Foo {
private one: string;
private two: string;
}`);
});
});