From edf0cec3ddd7f0f8c7a1b58501668e6b9c70ddd0 Mon Sep 17 00:00:00 2001 From: Gabriela Araujo Britto Date: Tue, 19 Feb 2019 14:22:59 -0800 Subject: [PATCH] add tests for inherited constructor and method --- ...tToNamedParameters_inheritedConstructor.ts | 21 ++++++++++++++++ ...onvertToNamedParameters_inheritedMethod.ts | 25 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/cases/fourslash/refactorConvertToNamedParameters_inheritedConstructor.ts create mode 100644 tests/cases/fourslash/refactorConvertToNamedParameters_inheritedMethod.ts diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedConstructor.ts b/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedConstructor.ts new file mode 100644 index 00000000000..743fc7fadb4 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedConstructor.ts @@ -0,0 +1,21 @@ +/// + +////class Foo { +//// /*a*/constructor/*b*/(t: string, s: string) { } +////} +////class Bar extends Foo { } +////var bar = new Bar("a", "b"); +////var foo = new Foo("c", "d"); + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert to named parameters", + actionName: "Convert to named parameters", + actionDescription: "Convert to named parameters", + newContent: `class Foo { + constructor({ t, s }: { t: string; s: string; }) { } +} +class Bar extends Foo { } +var bar = new Bar({ t: "a", s: "b" }); +var foo = new Foo({ t: "c", s: "d" })` +}); \ No newline at end of file diff --git a/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedMethod.ts b/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedMethod.ts new file mode 100644 index 00000000000..3214ea4bf53 --- /dev/null +++ b/tests/cases/fourslash/refactorConvertToNamedParameters_inheritedMethod.ts @@ -0,0 +1,25 @@ +/// + +////class Foo { +//// /*a*/bar/*b*/(t: string, s: string): string { +//// return s + t; +//// } +////} +////class Bar extends Foo { } +////var bar = new Bar(); +////bar.bar("a", "b"); + +goTo.select("a", "b"); +edit.applyRefactor({ + refactorName: "Convert to named parameters", + actionName: "Convert to named parameters", + actionDescription: "Convert to named parameters", + newContent: `class Foo { + bar({ t, s }: { t: string; s: string; }): string { + return s + t; + } +} +class Bar extends Foo { } +var bar = new Bar(); +bar.bar({ t: "a", s: "b" });` +}); \ No newline at end of file