add tests to add and remove members in class

This commit is contained in:
Vladimir Matveev 2017-03-14 22:36:38 -07:00
parent 323aa3a56c
commit c687add579
5 changed files with 90 additions and 0 deletions

View file

@ -667,5 +667,47 @@ class A {
}
});
}
{
const text = `
class A {
x
}
`;
runSingleFileTest("insertNodeAfterInClass1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), createProperty(undefined, undefined, "a", undefined, createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined), { suffix: newLineCharacter });
});
}
{
const text = `
class A {
x;
}
`;
runSingleFileTest("insertNodeAfterInClass2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), createProperty(undefined, undefined, "a", undefined, createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined), { suffix: newLineCharacter });
});
}
{
const text = `
class A {
x;
y = 1;
}
`;
runSingleFileTest("deleteNodeAfterInClass1", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.deleteNode(sourceFile, findChild("x", sourceFile));
});
}
{
const text = `
class A {
x
y = 1;
}
`;
runSingleFileTest("deleteNodeAfterInClass2", noop, text, /*validateNodes*/ false, (sourceFile, changeTracker) => {
changeTracker.deleteNode(sourceFile, findChild("x", sourceFile));
});
}
});
}

View file

@ -0,0 +1,12 @@
===ORIGINAL===
class A {
x;
y = 1;
}
===MODIFIED===
class A {
y = 1;
}

View file

@ -0,0 +1,12 @@
===ORIGINAL===
class A {
x
y = 1;
}
===MODIFIED===
class A {
y = 1;
}

View file

@ -0,0 +1,12 @@
===ORIGINAL===
class A {
x
}
===MODIFIED===
class A {
x
a: boolean;
}

View file

@ -0,0 +1,12 @@
===ORIGINAL===
class A {
x;
}
===MODIFIED===
class A {
x;
a: boolean;
}