rename refactor tests

This commit is contained in:
Gabriela Araujo Britto 2019-02-15 15:36:11 -08:00
parent 05e9d6c9de
commit b93afffaf7
34 changed files with 109 additions and 66 deletions

View File

@ -1,7 +0,0 @@
/// <reference path='fourslash.ts' />
////const { foo, bar } = { foo: /*a*/(a: number, b: number)/*b*/ => {}, bar: () => {} };
////foo(1, 2);
goTo.select("a", "b");
verify.not.refactorAvailable("Convert to named parameters");

View File

@ -1,24 +0,0 @@
/// <reference path='fourslash.ts' />
////class Foo {
//// /*a*/bar/*b*/(t: string, s: string): string {
//// return s + t;
//// }
////}
////var foo = {};
////foo['bar']("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 Foo {
bar({ t, s }: { t: string; s: string; }): string {
return s + t;
}
}
var foo = {};
foo['bar']("a", "b");`
});

View File

@ -1,12 +0,0 @@
/// <reference path='fourslash.ts' />
////function /*a*/foo/*b*/(// comment
//// /** other comment */ a: number, b: number) { }
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
newContent: `function foo(// comment { a, b }: { /** other comment */ a: number; b: number; }) { }`
});

View File

@ -1,17 +0,0 @@
/// <reference path='fourslash.ts' />
////function f(/*a*/a: number, b = 1/*b*/) {
//// return b;
////}
////f(2);
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
newContent: `function f({ a, b = 1 }: { a: number; b?: number; }) {
return b;
}
f({ a: 2 });`
});

View File

@ -0,0 +1,25 @@
/// <reference path='fourslash.ts' />
////function /*a*/foo/*b*/(a: number, b: number, ...rest: number[]) {
//// return a + b;
////}
////foo(
//// /**a*/
//// 1,
//// /**c*/
//// 2,
//// /**e*/
//// 3,
//// /**g*/
//// 4);
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, rest = [] }: { a: number; b: number; rest?: number[]; }) {
return a + b;
}
foo({ a: /**a*/ 1, b: /**c*/ 2, rest: [/**e*/ 3, /**g*/ 4] });`
});

View File

@ -1,6 +1,6 @@
/// <reference path='fourslash.ts' />
////function /*a*/foo/*b*/(a: number, b: number) { /** missing */
////function /*a*/foo/*b*/(a: number /** a */, b: number /** b */) {
//// return a + b;
////}
@ -9,7 +9,7 @@ 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; }) { /** missing */
newContent: `function foo({ a, b }: { a: number /** a */; b: number /** b */; }) {
return a + b;
}`
});

View File

@ -1,7 +1,13 @@
/// <reference path='fourslash.ts' />
////function /*a*/foo/*b*/(// comment
//// a: number, b: number) { }
//// // a comment
//// a: number,
//// // b comment
//// b: number
////) {
//// return a + b;
////}
goTo.select("a", "b");
edit.applyRefactor({
@ -9,5 +15,12 @@ edit.applyRefactor({
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
newContent: `function foo(// comment
{ a, b }: { a: number; b: number }) { }`
{ a, b }: {
// a comment
a: number;
// b comment
b: number;
}) {
return a + b;
}`
});

View File

@ -1,7 +1,7 @@
/// <reference path='fourslash.ts' />
////function foo<T, S>(/*a*/t: T, s: S/*b*/) {
//// return s;
//// return s;
////}
////foo("a", "b");

View File

@ -0,0 +1,45 @@
/// <reference path='fourslash.ts' />
////class A {
//// /*a*/foo/*b*/(a: number, b: number) { }
////}
////class B extends A {
//// /*c*/foo/*d*/(c: number, d: number) { }
////}
////var a = new A();
////a.foo(3, 4);
////var b = new B();
////b.foo(5, 6);
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
newContent: `class A {
foo(a: number, b: number) { }
}
class B extends A {
foo(c: number, d: number) { }
}
var a = new A();
a.foo(3, 4);
var b = new B();
b.foo(5, 6);`
});
goTo.select("c", "d");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
newContent: `class A {
foo(a: number, b: number) { }
}
class B extends A {
foo(c: number, d: number) { }
}
var a = new A();
a.foo(3, 4);
var b = new B();
b.foo(5, 6);`
});

View File

@ -0,0 +1,20 @@
/// <reference path='fourslash.ts' />
////const f = function foo(/*a*/a: number, b: number/*b*/) {
//// foo(1, 2);
////}
////function foo(a: number, b: number) { }
////foo(3, 4);
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
newContent: `const f = function foo({ a, b }: { a: number; b: number; }) {
foo({ a: 1, b: 2 });
}
function foo(a: number, b: number) { }
foo(3, 4);`
});

View File

@ -1,7 +1,7 @@
/// <reference path='fourslash.ts' />
////function foo(this: void, /*a*/t: string, s: string/*b*/) {
//// return s;
//// return s;
////}
////foo("a", "b");