add tests for comments

This commit is contained in:
Gabriela Araujo Britto 2019-02-11 12:03:09 -08:00
parent dba631de80
commit 4e135f13b5
5 changed files with 80 additions and 0 deletions

View File

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

View File

@ -0,0 +1,23 @@
/// <reference path='fourslash.ts' />
////foo(1, 2); /**a*/
/////**b*/ function /*a*/foo/*b*/(/**this1*/ this /**this2*/: /**void1*/ void /**void2*/, /**c*/ a /**d*/: /**e*/ number /**f*/, /**g*/ b /**h*/: /**i*/ number /**j*/ = /**k*/ 1 /**l*/) {
//// // m
//// /**n*/ return a + b; // o
//// // p
////} // q
/////**r*/ foo(1);
goTo.select("a", "b");
edit.applyRefactor({
refactorName: "Convert to named parameters",
actionName: "Convert to named parameters",
actionDescription: "Convert to named parameters",
newContent: `foo({ a: 1, b: 2 }); /**a*/
/**b*/ function foo(/**this1*/ this /**this2*/: /**void1*/ void /**void2*/, { a, b = /**k*/ 1 /**l*/ }: { /**c*/ a /**d*/: /**e*/ number /**f*/; /**g*/ b /**h*/?: /**i*/ number /**j*/; }) {
// m
/**n*/ return a + b; // o
// p
} // q
/**r*/ foo({ a: 1 });`
});

View File

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

View File

@ -0,0 +1,12 @@
/// <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

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