summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorawait-ovo <13152410380@163.com>2023-08-02 07:20:08 +0800
committerGitHub <noreply@github.com>2023-08-01 23:20:08 +0000
commitfec34d8069517be195193cd3578e7988d39fd0e1 (patch)
tree3fa2192d9bdd9a6d3e20b7fe32b726f86cde2e09 /cli/tests
parent21f1b2f62b1fac9089c214d9b862fce2359d30fd (diff)
fix(ext/node): fix import json using npm specifier (#19723)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/npm_tests.rs14
-rw-r--r--cli/tests/testdata/npm/dynamic_import_json/main.js4
-rw-r--r--cli/tests/testdata/npm/dynamic_import_json/main.out14
-rw-r--r--cli/tests/testdata/npm/import_json/main.js4
-rw-r--r--cli/tests/testdata/npm/import_json/main.out10
5 files changed, 46 insertions, 0 deletions
diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs
index ddb815a15..34b6add26 100644
--- a/cli/tests/integration/npm_tests.rs
+++ b/cli/tests/integration/npm_tests.rs
@@ -2119,6 +2119,20 @@ itest!(reserved_word_exports {
http_server: true,
});
+itest!(import_json {
+ args: "run -A --quiet npm/import_json/main.js",
+ output: "npm/import_json/main.out",
+ envs: env_vars_for_npm_tests(),
+ http_server: true,
+});
+
+itest!(dynamic_import_json {
+ args: "run -A --quiet npm/import_json/main.js",
+ output: "npm/import_json/main.out",
+ envs: env_vars_for_npm_tests(),
+ http_server: true,
+});
+
itest!(check_package_file_dts_dmts_dcts {
args: "check npm/file_dts_dmts_dcts/main.ts",
output: "npm/file_dts_dmts_dcts/main.out",
diff --git a/cli/tests/testdata/npm/dynamic_import_json/main.js b/cli/tests/testdata/npm/dynamic_import_json/main.js
new file mode 100644
index 000000000..6d8abfc9e
--- /dev/null
+++ b/cli/tests/testdata/npm/dynamic_import_json/main.js
@@ -0,0 +1,4 @@
+const info = await import("npm:@denotest/binary-package@1/package.json", {
+ assert: { type: "json" },
+});
+console.log(json);
diff --git a/cli/tests/testdata/npm/dynamic_import_json/main.out b/cli/tests/testdata/npm/dynamic_import_json/main.out
new file mode 100644
index 000000000..07f48e8a5
--- /dev/null
+++ b/cli/tests/testdata/npm/dynamic_import_json/main.out
@@ -0,0 +1,14 @@
+[Module: null prototype] {
+ default: {
+ {
+ name: "@denotest/binary-package",
+ version: "1.0.0",
+ main: "index.js",
+ optionalDependencies: {
+ "@denotest/binary-package-linux": "1.0.0",
+ "@denotest/binary-package-mac": "1.0.0",
+ "@denotest/binary-package-windows": "1.0.0"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/cli/tests/testdata/npm/import_json/main.js b/cli/tests/testdata/npm/import_json/main.js
new file mode 100644
index 000000000..b752bdef8
--- /dev/null
+++ b/cli/tests/testdata/npm/import_json/main.js
@@ -0,0 +1,4 @@
+import json from "npm:@denotest/binary-package@1/package.json" assert {
+ type: "json",
+};
+console.log(json);
diff --git a/cli/tests/testdata/npm/import_json/main.out b/cli/tests/testdata/npm/import_json/main.out
new file mode 100644
index 000000000..7db7ec4ea
--- /dev/null
+++ b/cli/tests/testdata/npm/import_json/main.out
@@ -0,0 +1,10 @@
+{
+ name: "@denotest/binary-package",
+ version: "1.0.0",
+ main: "index.js",
+ optionalDependencies: {
+ "@denotest/binary-package-linux": "1.0.0",
+ "@denotest/binary-package-mac": "1.0.0",
+ "@denotest/binary-package-windows": "1.0.0"
+ }
+}