add more testcases

This commit is contained in:
BigAru 2018-11-09 09:51:51 +01:00
parent dfb86acbb9
commit e1dc52f06e
8 changed files with 78 additions and 9 deletions

View file

@ -0,0 +1,15 @@
/// <reference path='fourslash.ts' />
//// function doSomething(a){}
//// doSomething(/*x*/(/*y*/) => 1 + 1);
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to anonymous function",
actionDescription: "Convert to anonymous function",
newContent: `function doSomething(a){}
doSomething(function() {
return 1 + 1;
});`,
});

View file

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts' />
//// [9,8,7].map(/*x*/n/*y*/ => n + 418);
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to anonymous function",
actionDescription: "Convert to anonymous function",
newContent: `[9,8,7].map(function(n) {
return n + 418;
});`,
});

View file

@ -1,13 +1,13 @@
/// <reference path='fourslash.ts' />
//// const foo = /*x*/(/*y*/): number => a + 1;
//// const increment = /*x*/(/*y*/a: number): number => a + 1;
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to anonymous function",
actionDescription: "Convert to anonymous function",
newContent: `const foo = function(): number {
newContent: `const increment = function(a: number): number {
return a + 1;
};`,
});

View file

@ -0,0 +1,15 @@
/// <reference path='fourslash.ts' />
//// function foo(lambda){}
//// foo(function /*x*/is/*y*/Even(n) {
//// return n % 2 === 0;
//// });
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to arrow function",
actionDescription: "Convert to arrow function",
newContent: `function foo(lambda){}
foo((n) => n % 2 === 0);`,
});

View file

@ -1,13 +1,13 @@
/// <reference path='fourslash.ts' />
//// const foo = /*x*/f/*y*/unction(): string {
//// return "foobar";
//// };
//// [4,5,6,7].map(function /*x*/is/*y*/Even(n) {
//// return n % 2 === 0;
//// });
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to arrow function",
actionDescription: "Convert to arrow function",
newContent: `const foo = (): string => "foobar";`,
newContent: `[4,5,6,7].map((n) => n % 2 === 0);`,
});

View file

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts' />
//// const concat = /*x*/f/*y*/unction(a: string, b: string): string {
//// return a + b;
//// };
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to arrow function",
actionDescription: "Convert to arrow function",
newContent: `const concat = (a: string, b: string): string => a + b;`,
});

View file

@ -0,0 +1,13 @@
/// <reference path='fourslash.ts' />
//// let isFoo = /*x*/(/*y*/n: number): boolean => n === 42;
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to named function",
actionDescription: "Convert to named function",
newContent: `function isFoo(n: number): boolean {
return n === 42;
}`,
});

View file

@ -1,13 +1,13 @@
/// <reference path='fourslash.ts' />
//// let foo = /*x*/(/*y*/): number => 42;
//// /*x*/let/*y*/ foo = a => 1 + a;
goTo.select("x", "y");
edit.applyRefactor({
refactorName: "Convert arrow function or function expression",
actionName: "Convert to named function",
actionDescription: "Convert to named function",
newContent: `function foo(): number {
return 42;
newContent: `function foo(a) {
return 1 + a;
}`,
});