mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
add test cases
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = `/*x*/w/*y*/ith back\`tick`
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to string concatenation",
|
||||
actionDescription: "Convert to string concatenation",
|
||||
newContent:
|
||||
"const foo = \"with back`tick\"",
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = `/*x*/f/*y*/oobar is ${ 42 + 6 } years old`
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to string concatenation",
|
||||
actionDescription: "Convert to string concatenation",
|
||||
newContent:
|
||||
`const foo = "foobar is " + (42 + 6) + " years old"`,
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = `/*x*/w/*y*/ith \${dollar}`
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to string concatenation",
|
||||
actionDescription: "Convert to string concatenation",
|
||||
newContent:
|
||||
"const foo = \"with ${dollar}\"",
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = `/*x*/f/*y*/oobar is ${ 42 }${ 6 } years old`
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to string concatenation",
|
||||
actionDescription: "Convert to string concatenation",
|
||||
newContent:
|
||||
`const foo = "foobar is " + 42 + 6 + " years old"`,
|
||||
});
|
||||
@@ -0,0 +1,16 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const age = 22
|
||||
//// const name = "Eddy"
|
||||
//// const foo = \`\${ /*x*/n/*y*/ame } is \${ age } years old\`
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to string concatenation",
|
||||
actionDescription: "Convert to string concatenation",
|
||||
newContent:
|
||||
`const age = 22
|
||||
const name = "Eddy"
|
||||
const foo = name + " is " + age + " years old"`,
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const age = 42
|
||||
//// const foo = `/*x*/f/*y*/oobar is a ${ age < 18 ? 'child' : `grown-up ${ age > 40 ? 'who needs probaply assistance': ''}` }`
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to string concatenation",
|
||||
actionDescription: "Convert to string concatenation",
|
||||
newContent:
|
||||
`const age = 42
|
||||
const foo = "foobar is a " + ( age < 18 ? 'child' : \`grown-up \${ age > 40 ? 'who needs probaply assistance': ''}\` ) `,
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const age = 42
|
||||
//// const foo = `/*x*/f/*y*/oobar is ${ age } years old`
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to string concatenation",
|
||||
actionDescription: "Convert to string concatenation",
|
||||
newContent:
|
||||
`const age = 42
|
||||
const foo = "foobar is " + age + " years old"`,
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = `/*x*/f/*y*/oobar rocks`
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to string concatenation",
|
||||
actionDescription: "Convert to string concatenation",
|
||||
newContent:
|
||||
`const foo = "foobar rocks"`,
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = "/*x*/w/*y*/ith back`tick"
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to template literal",
|
||||
actionDescription: "Convert to template literal",
|
||||
newContent:
|
||||
"const foo = `with back\`tick`",
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = "/*x*/w/*y*/ith ${dollar}"
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to template literal",
|
||||
actionDescription: "Convert to template literal",
|
||||
newContent:
|
||||
"const foo = `with \${dollar}`",
|
||||
});
|
||||
@@ -0,0 +1,12 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = "/*x*/f/*y*/oobar is " + 42 + 6 + " years old"
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to template literal",
|
||||
actionDescription: "Convert to template literal",
|
||||
newContent:
|
||||
`const foo = \`foobar is \${ 42 }\${ 6 } years old\``,
|
||||
});
|
||||
@@ -0,0 +1,18 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = "/*x*/w/*y*/ait for others\n"
|
||||
//// + "D'oh!\n"
|
||||
//// + ""Yada, yada, yada\n"
|
||||
//// + "Hasta la vista, baby!"
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to template literal",
|
||||
actionDescription: "Convert to template literal",
|
||||
newContent:
|
||||
`const foo = \`wait for others
|
||||
D'oh!
|
||||
Yada, yada, yada
|
||||
Hasta la vista, baby!\``,
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
/// <reference path='fourslash.ts' />
|
||||
|
||||
//// const foo = "/*x*/w/*y*/ait for new line\n"
|
||||
//// + "bada bum!"
|
||||
|
||||
goTo.select("x", "y");
|
||||
edit.applyRefactor({
|
||||
refactorName: "Convert string concatenation or template literal",
|
||||
actionName: "Convert to template literal",
|
||||
actionDescription: "Convert to template literal",
|
||||
newContent:
|
||||
`const foo = \`wait for new line
|
||||
bada bum!\``,
|
||||
});
|
||||
Reference in New Issue
Block a user