From abf6ca8e5eb1dacb1b5320f74bc65d6ea9026b88 Mon Sep 17 00:00:00 2001 From: Daniel Tschinder Date: Thu, 15 Sep 2016 19:24:11 +0200 Subject: [PATCH] Add tests for export extensions (#127) The case which includes a namespaced and default import was not tested yet --- .../default-and-ns/actual.js | 1 + .../default-and-ns/expected.json | 135 ++++++++++++++++++ .../export-extensions/default/actual.js | 1 + .../export-extensions/default/expected.json | 103 +++++++++++++ .../export-extensions/ns/actual.js | 1 + .../export-extensions/ns/expected.json | 103 +++++++++++++ .../export-extensions/options.json | 4 + 7 files changed, 348 insertions(+) create mode 100644 test/fixtures/experimental/export-extensions/default-and-ns/actual.js create mode 100644 test/fixtures/experimental/export-extensions/default-and-ns/expected.json create mode 100644 test/fixtures/experimental/export-extensions/default/actual.js create mode 100644 test/fixtures/experimental/export-extensions/default/expected.json create mode 100644 test/fixtures/experimental/export-extensions/ns/actual.js create mode 100644 test/fixtures/experimental/export-extensions/ns/expected.json create mode 100644 test/fixtures/experimental/export-extensions/options.json diff --git a/test/fixtures/experimental/export-extensions/default-and-ns/actual.js b/test/fixtures/experimental/export-extensions/default-and-ns/actual.js new file mode 100644 index 0000000000..01fa3e806a --- /dev/null +++ b/test/fixtures/experimental/export-extensions/default-and-ns/actual.js @@ -0,0 +1 @@ +export B, * as A from 'test'; diff --git a/test/fixtures/experimental/export-extensions/default-and-ns/expected.json b/test/fixtures/experimental/export-extensions/default-and-ns/expected.json new file mode 100644 index 0000000000..5880077cce --- /dev/null +++ b/test/fixtures/experimental/export-extensions/default-and-ns/expected.json @@ -0,0 +1,135 @@ +{ + "type": "File", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "sourceType": "module", + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 29, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "specifiers": [ + { + "type": "ExportDefaultSpecifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "exported": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "B" + }, + "name": "B" + } + }, + { + "type": "ExportNamespaceSpecifier", + "start": 10, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "exported": { + "type": "Identifier", + "start": 15, + "end": 16, + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 1, + "column": 16 + }, + "identifierName": "A" + }, + "name": "A" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 22, + "end": 28, + "loc": { + "start": { + "line": 1, + "column": 22 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "extra": { + "rawValue": "test", + "raw": "'test'" + }, + "value": "test" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/experimental/export-extensions/default/actual.js b/test/fixtures/experimental/export-extensions/default/actual.js new file mode 100644 index 0000000000..8493ca5743 --- /dev/null +++ b/test/fixtures/experimental/export-extensions/default/actual.js @@ -0,0 +1 @@ +export A from 'test'; diff --git a/test/fixtures/experimental/export-extensions/default/expected.json b/test/fixtures/experimental/export-extensions/default/expected.json new file mode 100644 index 0000000000..850834e228 --- /dev/null +++ b/test/fixtures/experimental/export-extensions/default/expected.json @@ -0,0 +1,103 @@ +{ + "type": "File", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "sourceType": "module", + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 21, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "specifiers": [ + { + "type": "ExportDefaultSpecifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "exported": { + "type": "Identifier", + "start": 7, + "end": 8, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 8 + }, + "identifierName": "A" + }, + "name": "A" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 14, + "end": 20, + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "extra": { + "rawValue": "test", + "raw": "'test'" + }, + "value": "test" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/experimental/export-extensions/ns/actual.js b/test/fixtures/experimental/export-extensions/ns/actual.js new file mode 100644 index 0000000000..27357f4758 --- /dev/null +++ b/test/fixtures/experimental/export-extensions/ns/actual.js @@ -0,0 +1 @@ +export * as A from 'test'; diff --git a/test/fixtures/experimental/export-extensions/ns/expected.json b/test/fixtures/experimental/export-extensions/ns/expected.json new file mode 100644 index 0000000000..b1affb10e9 --- /dev/null +++ b/test/fixtures/experimental/export-extensions/ns/expected.json @@ -0,0 +1,103 @@ +{ + "type": "File", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "sourceType": "module", + "body": [ + { + "type": "ExportNamedDeclaration", + "start": 0, + "end": 26, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 26 + } + }, + "specifiers": [ + { + "type": "ExportNamespaceSpecifier", + "start": 7, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "exported": { + "type": "Identifier", + "start": 12, + "end": 13, + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + }, + "identifierName": "A" + }, + "name": "A" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 19, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 19 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "extra": { + "rawValue": "test", + "raw": "'test'" + }, + "value": "test" + } + } + ], + "directives": [] + } +} \ No newline at end of file diff --git a/test/fixtures/experimental/export-extensions/options.json b/test/fixtures/experimental/export-extensions/options.json new file mode 100644 index 0000000000..15b0cf1ea2 --- /dev/null +++ b/test/fixtures/experimental/export-extensions/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["exportExtensions"], + "sourceType": "module" +}