mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
add tests for comments
This commit is contained in:
parent
dba631de80
commit
4e135f13b5
15
tests/cases/fourslash/refactorConvertToNamedParameters25.ts
Normal file
15
tests/cases/fourslash/refactorConvertToNamedParameters25.ts
Normal 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;
|
||||
}`
|
||||
});
|
||||
23
tests/cases/fourslash/refactorConvertToNamedParameters26.ts
Normal file
23
tests/cases/fourslash/refactorConvertToNamedParameters26.ts
Normal 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 });`
|
||||
});
|
||||
17
tests/cases/fourslash/refactorConvertToNamedParameters27.ts
Normal file
17
tests/cases/fourslash/refactorConvertToNamedParameters27.ts
Normal 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*/] });`
|
||||
});
|
||||
12
tests/cases/fourslash/refactorConvertToNamedParameters28.ts
Normal file
12
tests/cases/fourslash/refactorConvertToNamedParameters28.ts
Normal 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; }) { }`
|
||||
});
|
||||
13
tests/cases/fourslash/refactorConvertToNamedParameters29.ts
Normal file
13
tests/cases/fourslash/refactorConvertToNamedParameters29.ts
Normal 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 }) { }`
|
||||
});
|
||||
Loading…
x
Reference in New Issue
Block a user