mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-19 20:37:00 -05:00
add more tests
This commit is contained in:
17
tests/cases/fourslash/refactorConvertToNamedParameters20.ts
Normal file
17
tests/cases/fourslash/refactorConvertToNamedParameters20.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////function foo(/*a*/a: number, b: number/*b*/) {
|
||||
//// return { bar: () => a + b };
|
||||
////}
|
||||
////var x = foo(1, 2).bar();
|
||||
|
||||
goTo.select("a", "b");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert to named parameters",
|
||||
actionName: "Convert to named parameters",
|
||||
actionDescription: "Convert to named parameters",
|
||||
newContent: `function foo({ a, b }: { a: number; b: number; }) {
|
||||
return { bar: () => a + b };
|
||||
}
|
||||
var x = foo({ a: 1, b: 2 }).bar();`
|
||||
});
|
||||
25
tests/cases/fourslash/refactorConvertToNamedParameters21.ts
Normal file
25
tests/cases/fourslash/refactorConvertToNamedParameters21.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////class A {
|
||||
//// constructor(/*a*/a: string, b: string/*b*/) { }
|
||||
////}
|
||||
////class B extends A {
|
||||
//// constructor(a: string, b: string, c: string) {
|
||||
//// super(a, b);
|
||||
//// }
|
||||
////}
|
||||
|
||||
goTo.select("a", "b");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert to named parameters",
|
||||
actionName: "Convert to named parameters",
|
||||
actionDescription: "Convert to named parameters",
|
||||
newContent: `class A {
|
||||
constructor({ a, b }: { a: string; b: string; }) { }
|
||||
}
|
||||
class B extends A {
|
||||
constructor(a: string, b: string, c: string) {
|
||||
super({ a: a, b: b });
|
||||
}
|
||||
}`
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
////const foo: (a: number, b: number) => number = /*a*/(a: number, b: number)/*b*/ => a + b;
|
||||
////foo(1, 2);
|
||||
|
||||
goTo.select("a", "b");
|
||||
verify.not.refactorAvailable("Convert to named parameters");
|
||||
Reference in New Issue
Block a user