From 6869bfa4c63121f60284c7a2e48c5db1ce86f9cc Mon Sep 17 00:00:00 2001 From: "Kevin (Kun) \"Kassimo\" Qian" Date: Sat, 26 Oct 2019 18:04:34 -0700 Subject: Support named imports/exports for subset of properties in JSON modules (#3210) --- cli/tests/050_more_jsons.ts | 7 +++++++ cli/tests/050_more_jsons.ts.out | 5 +++++ cli/tests/integration_tests.rs | 5 +++++ cli/tests/subdir/json_1.json | 5 +++++ cli/tests/subdir/json_2.json | 1 + 5 files changed, 23 insertions(+) create mode 100644 cli/tests/050_more_jsons.ts create mode 100644 cli/tests/050_more_jsons.ts.out create mode 100644 cli/tests/subdir/json_1.json create mode 100644 cli/tests/subdir/json_2.json (limited to 'cli/tests') diff --git a/cli/tests/050_more_jsons.ts b/cli/tests/050_more_jsons.ts new file mode 100644 index 000000000..90deabcd1 --- /dev/null +++ b/cli/tests/050_more_jsons.ts @@ -0,0 +1,7 @@ +import j1, { $var } from "./subdir/json_1.json"; +import j2 from "./subdir/json_2.json"; +console.log($var); +console.log($var.a); +console.log(j1); +console.log(j1["with space"]); +console.log(j2); diff --git a/cli/tests/050_more_jsons.ts.out b/cli/tests/050_more_jsons.ts.out new file mode 100644 index 000000000..0ca014a21 --- /dev/null +++ b/cli/tests/050_more_jsons.ts.out @@ -0,0 +1,5 @@ +{ a: 123, b: [ 1, 2, 3 ], c: null } +123 +{ $var: { a: 123, b: [ 1, 2, 3 ], c: null }, with space: "invalid variable name", function: "reserved word" } +invalid variable name +just a string diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 909acfe04..ee8f1384c 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -343,6 +343,11 @@ itest!(_049_info_flag_script_jsx { http_server: true, }); +itest!(_050_more_jsons { + args: "run --reload 050_more_jsons.ts", + output: "050_more_jsons.ts.out", +}); + itest!(async_error { exit_code: 1, args: "run --reload async_error.ts", diff --git a/cli/tests/subdir/json_1.json b/cli/tests/subdir/json_1.json new file mode 100644 index 000000000..754d16b84 --- /dev/null +++ b/cli/tests/subdir/json_1.json @@ -0,0 +1,5 @@ +{ + "$var": { "a": 123, "b": [1, 2, 3], "c": null }, + "with space": "invalid variable name", + "function": "reserved word" +} diff --git a/cli/tests/subdir/json_2.json b/cli/tests/subdir/json_2.json new file mode 100644 index 000000000..7deb8b173 --- /dev/null +++ b/cli/tests/subdir/json_2.json @@ -0,0 +1 @@ +"just a string" -- cgit v1.2.3