diff options
author | Matt Mastracci <matthew@mastracci.com> | 2024-02-10 13:22:13 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-10 20:22:13 +0000 |
commit | f5e46c9bf2f50d66a953fa133161fc829cecff06 (patch) | |
tree | 8faf2f5831c1c7b11d842cd9908d141082c869a5 /tests/integration/doc_tests.rs | |
parent | d2477f780630a812bfd65e3987b70c0d309385bb (diff) |
chore: move cli/tests/ -> tests/ (#22369)
This looks like a massive PR, but it's only a move from cli/tests ->
tests, and updates of relative paths for files.
This is the first step towards aggregate all of the integration test
files under tests/, which will lead to a set of integration tests that
can run without the CLI binary being built.
While we could leave these tests under `cli`, it would require us to
keep a more complex directory structure for the various test runners. In
addition, we have a lot of complexity to ignore various test files in
the `cli` project itself (cargo publish exclusion rules, autotests =
false, etc).
And finally, the `tests/` folder will eventually house the `test_ffi`,
`test_napi` and other testing code, reducing the size of the root repo
directory.
For easier review, the extremely large and noisy "move" is in the first
commit (with no changes -- just a move), while the remainder of the
changes to actual files is in the second commit.
Diffstat (limited to 'tests/integration/doc_tests.rs')
-rw-r--r-- | tests/integration/doc_tests.rs | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/tests/integration/doc_tests.rs b/tests/integration/doc_tests.rs new file mode 100644 index 000000000..62fd2a5b4 --- /dev/null +++ b/tests/integration/doc_tests.rs @@ -0,0 +1,152 @@ +// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. + +use test_util as util; +use util::assert_contains; +use util::TestContext; + +itest!(deno_doc_builtin { + args: "doc", + output: "doc/deno_doc_builtin.out", +}); + +#[test] +fn deno_doc() { + let context = TestContext::default(); + // try this twice to ensure it works with the cache + for _ in 0..2 { + let output = context + .new_command() + .env("NO_COLOR", "1") + .args("doc doc/deno_doc.ts doc/deno_doc2.ts") + .split_output() + .run(); + + output.assert_exit_code(0); + assert_contains!(output.stdout(), "function foo"); + assert_contains!(output.stdout(), "function bar"); + } +} + +itest!(deno_doc_import_map { + args: "doc --import-map=doc/import_map.json doc/use_import_map.js", + output: "doc/use_import_map.out", +}); + +itest!(deno_doc_types_hint { + args: "doc doc/types_hint.ts", + output: "doc/types_hint.out", +}); + +itest!(deno_doc_types_ref { + args: "doc doc/types_ref.js", + output: "doc/types_ref.out", +}); + +itest!(deno_doc_types_header { + args: "doc --reload doc/types_header.ts", + output: "doc/types_header.out", + http_server: true, +}); + +itest!(deno_doc_referenced_private_types { + args: "doc doc/referenced_private_types.ts", + output: "doc/referenced_private_types.out", +}); + +itest!(deno_doc_lint_referenced_private_types_error { + args: "doc --lint doc/referenced_private_types.ts", + exit_code: 1, + output: "doc/referenced_private_types_lint.out", +}); + +itest!(deno_doc_lint_referenced_private_types_fixed { + args: "doc --lint doc/referenced_private_types_fixed.ts", + output: "doc/referenced_private_types_fixed.out", +}); + +itest!(deno_doc_html_lint_referenced_private_types_fixed { + args: "doc --lint --html --name=Library doc/referenced_private_types.ts", + exit_code: 1, + output: "doc/referenced_private_types_lint.out", +}); + +itest!(deno_doc_lint_success { + args: "doc --lint doc/lint_success.ts", + output: "doc/lint_success.out", +}); + +itest!(deno_doc_lint_json_success { + args: "doc --lint --json doc/lint_success.ts", + output: "doc/lint_success_json.out", +}); + +itest!(deno_doc_lint_html_success { + args: "doc --lint --html --name=Library lint_success.ts", + copy_temp_dir: Some("doc"), + cwd: Some("doc"), + output: "doc/lint_success_html.out", +}); + +itest!(_060_deno_doc_displays_all_overloads_in_details_view { + args: + "doc --filter NS.test doc/060_deno_doc_displays_all_overloads_in_details_view.ts", + output: "doc/060_deno_doc_displays_all_overloads_in_details_view.ts.out", +}); + +itest!(deno_doc_types_header_direct { + args: "doc --reload http://127.0.0.1:4545/xTypeScriptTypes.js", + output: "doc/types_header.out", + http_server: true, +}); + +itest!(deno_doc_invalid_url { + args: "doc https://raw.githubusercontent.com%2Fdyedgreen%2Fdeno-sqlite%2Frework_api%2Fmod.ts", + output: "doc/invalid_url.out", + exit_code: 1, +}); + +itest!(doc_lock { + args: "doc main.ts", + http_server: true, + cwd: Some("lockfile/basic"), + exit_code: 10, + output: "lockfile/basic/fail.out", +}); + +itest!(doc_no_lock { + args: "doc --no-lock main.ts", + http_server: true, + cwd: Some("lockfile/basic"), + output: "lockfile/basic/doc.nolock.out", +}); + +#[test] +fn deno_doc_html() { + let context = TestContext::default(); + let temp_dir = context.temp_dir(); + let output = context + .new_command() + .env("NO_COLOR", "1") + .args_vec(vec![ + "doc", + "--html", + "--name=MyLib", + &format!("--output={}", temp_dir.path().to_string_lossy()), + "doc/referenced_private_types_fixed.ts", + ]) + .split_output() + .run(); + + output.assert_exit_code(0); + assert_contains!(output.stderr(), "Written 10 files to"); + assert!(temp_dir.path().join("all_symbols.html").exists()); + assert!(temp_dir.path().join("index.html").exists()); + assert!(temp_dir.path().join("fuse.js").exists()); + assert!(temp_dir.path().join("page.css").exists()); + assert!(temp_dir.path().join("search.js").exists()); + assert!(temp_dir.path().join("search_index.js").exists()); + assert!(temp_dir.path().join("styles.css").exists()); + assert!(temp_dir.path().join("~/MyInterface.html").exists()); + assert!(temp_dir.path().join("~/MyClass.html").exists()); + assert!(temp_dir.path().join("~/index.html").exists()); +} |