From e51ed593be4134a7028a2afc23a97b8ef5a48c6f Mon Sep 17 00:00:00 2001 From: Boopathi Rajaa Date: Sat, 18 Nov 2017 21:23:36 +0100 Subject: [PATCH] refactor(tests): Tests to fixtures - memberExpressionLiterals (#729) --- .../fixtures/computed-props/actual.js | 1 + .../fixtures/computed-props/expected.js | 1 + .../__tests__/fixtures/invalid-ids/actual.js | 2 + .../fixtures/invalid-ids/expected.js | 2 + .../fixtures/leading-zeros/actual.js | 1 + .../fixtures/leading-zeros/expected.js | 1 + .../fixtures/member-expressions/actual.js | 1 + .../fixtures/member-expressions/expected.js | 1 + .../fixtures/numeric-literal/actual.js | 1 + .../fixtures/numeric-literal/expected.js | 1 + .../fixtures/string-literal/actual.js | 1 + .../fixtures/string-literal/expected.js | 1 + .../__tests__/index.js | 2 + ...ansform-member-expression-literals-test.js | 54 ------------------- 14 files changed, 16 insertions(+), 54 deletions(-) create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/computed-props/actual.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/computed-props/expected.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/invalid-ids/actual.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/invalid-ids/expected.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/leading-zeros/actual.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/leading-zeros/expected.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/member-expressions/actual.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/member-expressions/expected.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/numeric-literal/actual.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/numeric-literal/expected.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/string-literal/actual.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/string-literal/expected.js create mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/index.js delete mode 100644 packages/babel-plugin-transform-member-expression-literals/__tests__/transform-member-expression-literals-test.js diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/computed-props/actual.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/computed-props/actual.js new file mode 100644 index 000000000..cc184985c --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/computed-props/actual.js @@ -0,0 +1 @@ +foo[a]; diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/computed-props/expected.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/computed-props/expected.js new file mode 100644 index 000000000..14b33022e --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/computed-props/expected.js @@ -0,0 +1 @@ +foo[a]; \ No newline at end of file diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/invalid-ids/actual.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/invalid-ids/actual.js new file mode 100644 index 000000000..235484a7f --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/invalid-ids/actual.js @@ -0,0 +1,2 @@ +foo["default"]; +foo["import"]; diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/invalid-ids/expected.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/invalid-ids/expected.js new file mode 100644 index 000000000..264f92eae --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/invalid-ids/expected.js @@ -0,0 +1,2 @@ +foo["default"]; +foo["import"]; \ No newline at end of file diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/leading-zeros/actual.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/leading-zeros/actual.js new file mode 100644 index 000000000..ed7ac3a24 --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/leading-zeros/actual.js @@ -0,0 +1 @@ +data["00"] = 5; diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/leading-zeros/expected.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/leading-zeros/expected.js new file mode 100644 index 000000000..be3724277 --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/leading-zeros/expected.js @@ -0,0 +1 @@ +data["00"] = 5; \ No newline at end of file diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/member-expressions/actual.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/member-expressions/actual.js new file mode 100644 index 000000000..69087aa15 --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/member-expressions/actual.js @@ -0,0 +1 @@ +foo.bar; diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/member-expressions/expected.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/member-expressions/expected.js new file mode 100644 index 000000000..ca784399d --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/member-expressions/expected.js @@ -0,0 +1 @@ +foo.bar; \ No newline at end of file diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/numeric-literal/actual.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/numeric-literal/actual.js new file mode 100644 index 000000000..cd771a5f7 --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/numeric-literal/actual.js @@ -0,0 +1 @@ +foo["1"]; diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/numeric-literal/expected.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/numeric-literal/expected.js new file mode 100644 index 000000000..37dd34c1e --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/numeric-literal/expected.js @@ -0,0 +1 @@ +foo[1]; \ No newline at end of file diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/string-literal/actual.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/string-literal/actual.js new file mode 100644 index 000000000..1452b190a --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/string-literal/actual.js @@ -0,0 +1 @@ +foo["bar"]; diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/string-literal/expected.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/string-literal/expected.js new file mode 100644 index 000000000..ca784399d --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/fixtures/string-literal/expected.js @@ -0,0 +1 @@ +foo.bar; \ No newline at end of file diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/index.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/index.js new file mode 100644 index 000000000..d7c81a111 --- /dev/null +++ b/packages/babel-plugin-transform-member-expression-literals/__tests__/index.js @@ -0,0 +1,2 @@ +const runner = require("test-runner"); +runner(__dirname); diff --git a/packages/babel-plugin-transform-member-expression-literals/__tests__/transform-member-expression-literals-test.js b/packages/babel-plugin-transform-member-expression-literals/__tests__/transform-member-expression-literals-test.js deleted file mode 100644 index 7fc20ec53..000000000 --- a/packages/babel-plugin-transform-member-expression-literals/__tests__/transform-member-expression-literals-test.js +++ /dev/null @@ -1,54 +0,0 @@ -jest.autoMockOff(); - -const thePlugin = require("test-transform")(require("../src/index")); - -describe("transform-member-expressions-literals-plugin", () => { - thePlugin( - "should minify string literals to dot notation", - ` - foo['bar']; - `, - ` - foo.bar; - ` - ); - - thePlugin( - "should minify numbers as strings to actual numbers", - ` - foo['1']; - `, - ` - foo[1]; - ` - ); - - thePlugin( - "should not strip necessaary quotes for numbers with leading zeroes", - ` - data['00'] = 5; - ` - ); - - thePlugin( - "should not transform invalid identifiers", - ` - foo["default"]; - foo["import"]; - ` - ); - - thePlugin( - "should not transform non-string properties", - ` - foo[a]; - ` - ); - - thePlugin( - "should not transform literals that are not computed", - ` - foo.bar; - ` - ); -});