add tests to add and remove members in class
This commit is contained in:
parent
323aa3a56c
commit
c687add579
5 changed files with 90 additions and 0 deletions
|
@ -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));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
===ORIGINAL===
|
||||
|
||||
class A {
|
||||
x;
|
||||
y = 1;
|
||||
}
|
||||
|
||||
===MODIFIED===
|
||||
|
||||
class A {
|
||||
y = 1;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
===ORIGINAL===
|
||||
|
||||
class A {
|
||||
x
|
||||
y = 1;
|
||||
}
|
||||
|
||||
===MODIFIED===
|
||||
|
||||
class A {
|
||||
y = 1;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
===ORIGINAL===
|
||||
|
||||
class A {
|
||||
x
|
||||
}
|
||||
|
||||
===MODIFIED===
|
||||
|
||||
class A {
|
||||
x
|
||||
a: boolean;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
===ORIGINAL===
|
||||
|
||||
class A {
|
||||
x;
|
||||
}
|
||||
|
||||
===MODIFIED===
|
||||
|
||||
class A {
|
||||
x;
|
||||
a: boolean;
|
||||
}
|
Loading…
Reference in a new issue