summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/run_tests.rs56
-rw-r--r--cli/tests/testdata/file_extensions/ts_with_js_extension.out2
-rw-r--r--cli/tests/testdata/file_extensions/ts_without_extension.out1
3 files changed, 56 insertions, 3 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index d46684905..b29f735c4 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -1824,6 +1824,56 @@ fn exec_path() {
assert_eq!(expected, actual);
}
+#[test]
+fn run_from_stdin_defaults_to_ts() {
+ let source_code = r#"
+interface Lollipop {
+ _: number;
+}
+console.log("executing typescript");
+"#;
+
+ let mut p = util::deno_cmd()
+ .arg("run")
+ .arg("--check")
+ .arg("-")
+ .stdin(std::process::Stdio::piped())
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let stdin = p.stdin.as_mut().unwrap();
+ stdin.write_all(source_code.as_bytes()).unwrap();
+ let result = p.wait_with_output().unwrap();
+ assert!(result.status.success());
+ let stdout_str = std::str::from_utf8(&result.stdout).unwrap().trim();
+ assert_eq!(stdout_str, "executing typescript");
+}
+
+#[test]
+fn run_from_stdin_ext() {
+ let source_code = r#"
+let i = 123;
+i = "hello"
+console.log("executing javascript");
+"#;
+
+ let mut p = util::deno_cmd()
+ .arg("run")
+ .args(["--ext", "js"])
+ .arg("--check")
+ .arg("-")
+ .stdin(std::process::Stdio::piped())
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap();
+ let stdin = p.stdin.as_mut().unwrap();
+ stdin.write_all(source_code.as_bytes()).unwrap();
+ let result = p.wait_with_output().unwrap();
+ assert!(result.status.success());
+ let stdout_str = std::str::from_utf8(&result.stdout).unwrap().trim();
+ assert_eq!(stdout_str, "executing javascript");
+}
+
#[cfg(windows)]
// Clippy suggests to remove the `NoStd` prefix from all variants. I disagree.
#[allow(clippy::enum_variant_names)]
@@ -3836,14 +3886,14 @@ itest!(js_without_extension {
});
itest!(ts_without_extension {
- args: "run --ext ts file_extensions/ts_without_extension",
+ args: "run --ext ts --check file_extensions/ts_without_extension",
output: "file_extensions/ts_without_extension.out",
exit_code: 0,
});
itest!(ext_flag_takes_precedence_over_extension {
- args: "run --ext ts file_extensions/ts_with_js_extension.js",
- output: "file_extensions/ts_with_extension.out",
+ args: "run --ext ts --check file_extensions/ts_with_js_extension.js",
+ output: "file_extensions/ts_with_js_extension.out",
exit_code: 0,
});
diff --git a/cli/tests/testdata/file_extensions/ts_with_js_extension.out b/cli/tests/testdata/file_extensions/ts_with_js_extension.out
new file mode 100644
index 000000000..1c3739bb9
--- /dev/null
+++ b/cli/tests/testdata/file_extensions/ts_with_js_extension.out
@@ -0,0 +1,2 @@
+Check [WILDCARD]/file_extensions/ts_with_js_extension.js
+executing typescript with extension
diff --git a/cli/tests/testdata/file_extensions/ts_without_extension.out b/cli/tests/testdata/file_extensions/ts_without_extension.out
index b15c063c8..e1f019f9e 100644
--- a/cli/tests/testdata/file_extensions/ts_without_extension.out
+++ b/cli/tests/testdata/file_extensions/ts_without_extension.out
@@ -1 +1,2 @@
+Check [WILDCARD]/file_extensions/ts_without_extension
executing typescript with no extension