TypeScript/tests/cases/fourslash/extract-method13.ts

59 lines
1.3 KiB
TypeScript
Raw Normal View History

2017-08-05 01:10:33 +02:00
/// <reference path='fourslash.ts' />
// Extracting from a static context should make static methods.
// Also checks that we correctly find non-conflicting names in static contexts.
//// class C {
//// static j = /*c*/1 + 1/*d*/;
2017-09-15 19:45:15 +02:00
//// constructor(q: string = /*a*/"hello"/*b*/) {
2017-08-05 01:10:33 +02:00
//// }
//// }
goTo.select('a', 'b');
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to method in class 'C'",
newContent:
`class C {
static j = 1 + 1;
constructor(q: string = C./*RENAME*/newMethod()) {
}
private static newMethod(): string {
2017-09-15 19:45:15 +02:00
return "hello";
}
}`
});
2017-08-05 01:10:33 +02:00
verify.currentFileContentIs(`class C {
static j = 1 + 1;
constructor(q: string = C.newMethod()) {
}
private static newMethod(): string {
2017-09-15 19:45:15 +02:00
return "hello";
}
}`);
2017-08-05 01:10:33 +02:00
goTo.select('c', 'd');
edit.applyRefactor({
refactorName: "Extract Symbol",
actionName: "function_scope_0",
actionDescription: "Extract to method in class 'C'",
newContent:
`class C {
static j = C./*RENAME*/newMethod_1();
constructor(q: string = C.newMethod()) {
2017-08-05 01:10:33 +02:00
}
private static newMethod_1() {
return 1 + 1;
2017-08-05 01:10:33 +02:00
}
private static newMethod(): string {
2017-09-15 19:45:15 +02:00
return "hello";
}
}`
});