diff options
Diffstat (limited to 'tests/integration/init_tests.rs')
-rw-r--r-- | tests/integration/init_tests.rs | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/integration/init_tests.rs b/tests/integration/init_tests.rs index 65a57eeea..757dcb021 100644 --- a/tests/integration/init_tests.rs +++ b/tests/integration/init_tests.rs @@ -170,3 +170,50 @@ Run these commands to get started output.assert_exit_code(0); output.assert_matches_text("Log from main.ts that already exists\n"); } + +#[tokio::test] +async fn init_subcommand_serve() { + let context = TestContextBuilder::for_jsr().use_temp_cwd().build(); + let cwd = context.temp_dir().path(); + + let output = context + .new_command() + .args("init --serve") + .split_output() + .run(); + + output.assert_exit_code(0); + + let stderr = output.stderr(); + assert_contains!(stderr, "Project initialized"); + assert_contains!(stderr, "deno serve -R main.ts"); + assert_contains!(stderr, "deno task dev"); + assert_contains!(stderr, "deno -R test"); + + assert!(cwd.join("deno.json").exists()); + + let mut child = context + .new_command() + .env("NO_COLOR", "1") + .args("serve -R --port 9500 main.ts") + .spawn_with_piped_output(); + + tokio::time::sleep(std::time::Duration::from_millis(1000)).await; + let resp = reqwest::get("http://127.0.0.1:9500").await.unwrap(); + + let body = resp.text().await.unwrap(); + assert_eq!(body, "Home page"); + + let _ = child.kill(); + + let output = context + .new_command() + .env("NO_COLOR", "1") + .args("-R test") + .split_output() + .run(); + + output.assert_exit_code(0); + assert_contains!(output.stdout(), "4 passed"); + output.skip_output_check(); +} |