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; - ` - ); -});