summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/compat_tests.rs14
-rw-r--r--cli/tests/integration/mod.rs2
-rw-r--r--cli/tests/testdata/compat/existing_import_map.json5
-rw-r--r--cli/tests/testdata/compat/existing_import_map.out5
-rw-r--r--cli/tests/testdata/compat/fs_promises.js3
-rw-r--r--cli/tests/testdata/compat/fs_promises.out2
-rw-r--r--cli/tests/testdata/compat/test.txt1
7 files changed, 32 insertions, 0 deletions
diff --git a/cli/tests/integration/compat_tests.rs b/cli/tests/integration/compat_tests.rs
new file mode 100644
index 000000000..4d93d370d
--- /dev/null
+++ b/cli/tests/integration/compat_tests.rs
@@ -0,0 +1,14 @@
+// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
+
+use crate::itest;
+
+itest!(fs_promises {
+ args: "run --compat --unstable -A compat/fs_promises.js",
+ output: "compat/fs_promises.out",
+});
+
+itest!(existing_import_map {
+ args: "run --compat --import-map compat/existing_import_map.json compat/fs_promises.js",
+ output: "compat/existing_import_map.out",
+ exit_code: 1,
+});
diff --git a/cli/tests/integration/mod.rs b/cli/tests/integration/mod.rs
index e3450c8a1..65a8a7516 100644
--- a/cli/tests/integration/mod.rs
+++ b/cli/tests/integration/mod.rs
@@ -54,6 +54,8 @@ macro_rules! itest_flaky(
mod bundle;
#[path = "cache_tests.rs"]
mod cache;
+#[path = "compat_tests.rs"]
+mod compat;
#[path = "compile_tests.rs"]
mod compile;
#[path = "coverage_tests.rs"]
diff --git a/cli/tests/testdata/compat/existing_import_map.json b/cli/tests/testdata/compat/existing_import_map.json
new file mode 100644
index 000000000..db59c0cc2
--- /dev/null
+++ b/cli/tests/testdata/compat/existing_import_map.json
@@ -0,0 +1,5 @@
+{
+ "imports": {
+ "fs/promises": "./non_existent_file.js"
+ }
+}
diff --git a/cli/tests/testdata/compat/existing_import_map.out b/cli/tests/testdata/compat/existing_import_map.out
new file mode 100644
index 000000000..0e319b115
--- /dev/null
+++ b/cli/tests/testdata/compat/existing_import_map.out
@@ -0,0 +1,5 @@
+[WILDCARD]
+Some Node built-ins were not added to the import map:
+ - "fs/promises" already exists and is mapped to "[WILDCARD]non_existent_file.js"
+If you want to use Node built-ins provided by Deno remove listed specifiers from "imports" mapping in the import map file.
+error: Cannot resolve module [WILDCARD] \ No newline at end of file
diff --git a/cli/tests/testdata/compat/fs_promises.js b/cli/tests/testdata/compat/fs_promises.js
new file mode 100644
index 000000000..3f7b4c935
--- /dev/null
+++ b/cli/tests/testdata/compat/fs_promises.js
@@ -0,0 +1,3 @@
+import fs from "fs/promises";
+const data = await fs.readFile("compat/test.txt", "utf-8");
+console.log(data);
diff --git a/cli/tests/testdata/compat/fs_promises.out b/cli/tests/testdata/compat/fs_promises.out
new file mode 100644
index 000000000..368d06776
--- /dev/null
+++ b/cli/tests/testdata/compat/fs_promises.out
@@ -0,0 +1,2 @@
+[WILDCARD]
+This is some example text that will be read using compatiblity mode.
diff --git a/cli/tests/testdata/compat/test.txt b/cli/tests/testdata/compat/test.txt
new file mode 100644
index 000000000..422e7b0c0
--- /dev/null
+++ b/cli/tests/testdata/compat/test.txt
@@ -0,0 +1 @@
+This is some example text that will be read using compatiblity mode. \ No newline at end of file