summaryrefslogtreecommitdiff
path: root/cli/tests/integration/lsp_tests.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-08-01 20:49:09 -0400
committerGitHub <noreply@github.com>2023-08-02 00:49:09 +0000
commit1cefa831fd74b14121494045a347024502d74e34 (patch)
treecc7791cf674e427fe4165262db416e6c537e99a3 /cli/tests/integration/lsp_tests.rs
parent36ae37604a0ddab4349df6eb6fafb8ae39fd20fc (diff)
feat(unstable): optional `deno_modules` directory (#19977)
Closes #15633
Diffstat (limited to 'cli/tests/integration/lsp_tests.rs')
-rw-r--r--cli/tests/integration/lsp_tests.rs94
1 files changed, 93 insertions, 1 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index a1a2b0258..a073cf30d 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -6643,7 +6643,7 @@ fn lsp_cache_location() {
);
let cache_path = temp_dir.path().join(".cache");
assert!(cache_path.is_dir());
- assert!(cache_path.join("gen").is_dir());
+ assert!(!cache_path.join("gen").is_dir()); // not created because no emitting has occurred
client.shutdown();
}
@@ -8766,3 +8766,95 @@ fn lsp_node_modules_dir() {
client.shutdown();
}
+
+#[test]
+fn lsp_deno_modules_dir() {
+ let context = TestContextBuilder::new()
+ .use_http_server()
+ .use_temp_cwd()
+ .build();
+ let temp_dir = context.temp_dir();
+
+ let mut client = context.new_lsp_command().build();
+ client.initialize_default();
+ let file_uri = temp_dir.uri().join("file.ts").unwrap();
+ client.did_open(json!({
+ "textDocument": {
+ "uri": file_uri,
+ "languageId": "typescript",
+ "version": 1,
+ "text": "import { returnsHi } from 'http://localhost:4545/subdir/mod1.ts'; console.log(returnsHi());",
+ }
+ }));
+ let cache = |client: &mut LspClient| {
+ client.write_request(
+ "deno/cache",
+ json!({
+ "referrer": {
+ "uri": file_uri,
+ },
+ "uris": [
+ {
+ "uri": "http://localhost:4545/subdir/mod1.ts",
+ }
+ ]
+ }),
+ );
+ };
+
+ cache(&mut client);
+
+ assert!(!temp_dir.path().join("deno_modules").exists());
+
+ temp_dir.write(
+ temp_dir.path().join("deno.json"),
+ "{ \"denoModulesDir\": true, \"lock\": false }\n",
+ );
+ let refresh_config = |client: &mut LspClient| {
+ client.write_notification(
+ "workspace/didChangeConfiguration",
+ json!({
+ "settings": {
+ "enable": true,
+ "config": "./deno.json",
+ }
+ }),
+ );
+
+ let request = json!([{
+ "enable": true,
+ "config": "./deno.json",
+ "codeLens": {
+ "implementations": true,
+ "references": true
+ },
+ "importMap": null,
+ "lint": false,
+ "suggest": {
+ "autoImports": true,
+ "completeFunctionCalls": false,
+ "names": true,
+ "paths": true,
+ "imports": {}
+ },
+ "unstable": false
+ }]);
+ // one for the workspace
+ client.handle_configuration_request(request.clone());
+ // one for the specifier
+ client.handle_configuration_request(request);
+ };
+ refresh_config(&mut client);
+
+ let diagnostics = client.read_diagnostics();
+ assert_eq!(diagnostics.all().len(), 0, "{:#?}", diagnostics); // cached
+
+ // no caching necessary because it was already cached. It should exist now
+
+ assert!(temp_dir
+ .path()
+ .join("deno_modules/http_localhost_4545/subdir/mod1.ts")
+ .exists());
+
+ client.shutdown();
+}