diff options
Diffstat (limited to 'cli/tests/integration_tests.rs')
-rw-r--r-- | cli/tests/integration_tests.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 3e2c28980..20de4b030 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -327,6 +327,48 @@ fn bundle_single_module() { } #[test] +fn bundle_tla() { + // First we have to generate a bundle of some module that has exports. + let tla_import = util::root_path().join("cli/tests/subdir/tla.ts"); + assert!(tla_import.is_file()); + let t = tempfile::TempDir::new().expect("tempdir fail"); + let bundle = t.path().join("tla.bundle.js"); + let mut deno = util::deno_cmd() + .current_dir(util::root_path()) + .arg("bundle") + .arg(tla_import) + .arg(&bundle) + .spawn() + .expect("failed to spawn script"); + let status = deno.wait().expect("failed to wait for the child process"); + assert!(status.success()); + assert!(bundle.is_file()); + + // Now we try to use that bundle from another module. + let test = t.path().join("test.js"); + std::fs::write( + &test, + " + import { foo } from \"./tla.bundle.js\"; + console.log(foo); ", + ) + .expect("error writing file"); + + let output = util::deno_cmd() + .current_dir(util::root_path()) + .arg("run") + .arg(&test) + .output() + .expect("failed to spawn script"); + // check the output of the test.ts program. + assert!(std::str::from_utf8(&output.stdout) + .unwrap() + .trim() + .ends_with("Hello")); + assert_eq!(output.stderr, b""); +} + +#[test] fn repl_test_console_log() { let (out, err, code) = util::repl_process(vec!["console.log('hello')", "'world'"], None); |