summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/npm_tests.rs9
-rw-r--r--cli/tests/testdata/npm/cjs_this_in_exports/main.js11
-rw-r--r--cli/tests/testdata/npm/cjs_this_in_exports/main.out5
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/cjs-this-in-exports/1.0.0/index.js8
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/cjs-this-in-exports/1.0.0/package.json5
-rw-r--r--cli/tests/testdata/npm/tarball_with_global_header/main.out2
-rw-r--r--cli/tests/testdata/npm/translate_cjs_to_esm/main.out2
7 files changed, 40 insertions, 2 deletions
diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs
index 463cec5a3..678734309 100644
--- a/cli/tests/integration/npm_tests.rs
+++ b/cli/tests/integration/npm_tests.rs
@@ -61,6 +61,14 @@ itest!(cjs_reexport_collision {
http_server: true,
});
+itest!(cjs_this_in_exports {
+ args: "run --allow-read --unstable --quiet npm/cjs_this_in_exports/main.js",
+ output: "npm/cjs_this_in_exports/main.out",
+ envs: env_vars(),
+ http_server: true,
+ exit_code: 1,
+});
+
itest!(translate_cjs_to_esm {
args: "run --unstable -A --quiet npm/translate_cjs_to_esm/main.js",
output: "npm/translate_cjs_to_esm/main.out",
@@ -422,6 +430,7 @@ fn env_vars_no_sync_download() -> Vec<(String, String)> {
"DENO_NPM_REGISTRY".to_string(),
"http://localhost:4545/npm/registry/".to_string(),
),
+ ("NO_COLOR".to_string(), "1".to_string()),
]
}
diff --git a/cli/tests/testdata/npm/cjs_this_in_exports/main.js b/cli/tests/testdata/npm/cjs_this_in_exports/main.js
new file mode 100644
index 000000000..03aaabe05
--- /dev/null
+++ b/cli/tests/testdata/npm/cjs_this_in_exports/main.js
@@ -0,0 +1,11 @@
+import defaultImport, { getValue } from "npm:@denotest/cjs-this-in-exports";
+import * as namespaceImport from "npm:@denotest/cjs-this-in-exports";
+
+console.log(defaultImport.getValue());
+// In Node this actually fails, but it seems to work in Deno
+// so I guess there's no harm in that.
+console.log(namespaceImport.getValue());
+
+// This will throw because it's lost its context.
+// (same thing occurs with Node's cjs -> esm translation)
+getValue();
diff --git a/cli/tests/testdata/npm/cjs_this_in_exports/main.out b/cli/tests/testdata/npm/cjs_this_in_exports/main.out
new file mode 100644
index 000000000..653a62335
--- /dev/null
+++ b/cli/tests/testdata/npm/cjs_this_in_exports/main.out
@@ -0,0 +1,5 @@
+1
+1
+error: Uncaught TypeError: this.otherMethod is not a function
+ at getValue (file://[WILDCARD]/@denotest/cjs-this-in-exports/1.0.0/index.js:3:17)
+ at file://[WILDCARD]/testdata/npm/cjs_this_in_exports/main.js:11:1
diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-this-in-exports/1.0.0/index.js b/cli/tests/testdata/npm/registry/@denotest/cjs-this-in-exports/1.0.0/index.js
new file mode 100644
index 000000000..21a9d7d7e
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/cjs-this-in-exports/1.0.0/index.js
@@ -0,0 +1,8 @@
+module.exports = {
+ getValue() {
+ return this.otherMethod();
+ },
+ otherMethod() {
+ return 1;
+ },
+};
diff --git a/cli/tests/testdata/npm/registry/@denotest/cjs-this-in-exports/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/cjs-this-in-exports/1.0.0/package.json
new file mode 100644
index 000000000..729b8c34e
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/cjs-this-in-exports/1.0.0/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "@denotest/cjs-this-in-exports",
+ "version": "1.0.0",
+ "main": "./index.js"
+}
diff --git a/cli/tests/testdata/npm/tarball_with_global_header/main.out b/cli/tests/testdata/npm/tarball_with_global_header/main.out
index c8016c362..2f309499e 100644
--- a/cli/tests/testdata/npm/tarball_with_global_header/main.out
+++ b/cli/tests/testdata/npm/tarball_with_global_header/main.out
@@ -1 +1 @@
-[Function: bound Client]
+[Function: Client]
diff --git a/cli/tests/testdata/npm/translate_cjs_to_esm/main.out b/cli/tests/testdata/npm/translate_cjs_to_esm/main.out
index a1f331331..c472472f3 100644
--- a/cli/tests/testdata/npm/translate_cjs_to_esm/main.out
+++ b/cli/tests/testdata/npm/translate_cjs_to_esm/main.out
@@ -1,2 +1,2 @@
[Function: access]
-[Function: bound createApp]
+[Function: createApp]