diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 42 | ||||
-rw-r--r-- | cli/tests/integration/run_tests.rs | 13 |
2 files changed, 55 insertions, 0 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index d540c5f37..d2cb36806 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -8958,5 +8958,47 @@ fn lsp_vendor_dir() { ); assert_eq!(diagnostics.all().len(), 2); + // now try doing a relative import into the vendor directory + client.write_notification( + "textDocument/didChange", + json!({ + "textDocument": { + "uri": local_file_uri, + "version": 2 + }, + "contentChanges": [ + { + "range": { + "start": { "line": 0, "character": 0 }, + "end": { "line": 2, "character": 0 }, + }, + "text": "import { returnsHi } from './vendor/subdir/mod1.ts';\nconst test: string = returnsHi();\nconsole.log(test);" + } + ] + }), + ); + + let diagnostics = client.read_diagnostics(); + + assert_eq!( + json!( + diagnostics + .messages_with_file_and_source(local_file_uri.as_str(), "deno") + .diagnostics + ), + json!([ + { + "range": { + "start": { "line": 0, "character": 26 }, + "end": { "line": 0, "character": 51 } + }, + "severity": 1, + "code": "resolver-error", + "source": "deno", + "message": "Importing from the vendor directory is not permitted. Use a remote specifier instead or disable vendoring." + } + ]), + ); + client.shutdown(); } diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 2ac6ed985..0c39c2b72 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -4580,4 +4580,17 @@ console.log(returnsHi());"#, .args("run --vendor http://localhost:4545/subdir/CAPITALS/hello_there.ts") .run() .assert_matches_text("hello there\n"); + + // now try importing directly from the vendor folder + temp_dir.write( + "main.ts", + r#"import { returnsHi } from './vendor/http_localhost_4545/subdir/mod1.ts'; +console.log(returnsHi());"#, + ); + deno_run_cmd + .run() + .assert_matches_text("error: Importing from the vendor directory is not permitted. Use a remote specifier instead or disable vendoring. + at [WILDCARD]/main.ts:1:27 +") + .assert_exit_code(1); } |