mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-11-18 20:11:14 +00:00
add tests to add and remove members in class
This commit is contained in:
1 parent
323aa3a56c
commit
c687add579
5 files changed
+90
No files matched your search
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user