add test cases

This commit is contained in:
BigAru
2018-12-05 08:30:22 +01:00
parent 7620615212
commit 2bb2a8246a
14 changed files with 172 additions and 0 deletions
@@ -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!\``,
});