diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 2050cf2b73..e22934dc32 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -1934,6 +1934,51 @@ mod tests { harness.run().await; } + #[tokio::test] + async fn test_hover_asset() { + let mut harness = LspTestHarness::new(vec![ + ("initialize_request.json", LspResponse::RequestAny), + ("initialized_notification.json", LspResponse::None), + ("did_open_notification_asset.json", LspResponse::None), + ("hover_request_asset_01.json", LspResponse::RequestAny), + ( + "virtual_text_document_request.json", + LspResponse::RequestAny, + ), + ( + "hover_request_asset_02.json", + LspResponse::Request( + 4, + json!({ + "contents": [ + { + "language": "typescript", + "value": "interface Date", + }, + "Enables basic storage and retrieval of dates and times." + ], + "range": { + "start": { + "line": 109, + "character": 10, + }, + "end": { + "line": 109, + "character": 14, + } + } + }), + ), + ), + ( + "shutdown_request.json", + LspResponse::Request(3, json!(null)), + ), + ("exit_notification.json", LspResponse::None), + ]); + harness.run().await; + } + #[tokio::test] async fn test_hover_disabled() { let mut harness = LspTestHarness::new(vec![ diff --git a/cli/tests/lsp/did_open_notification_asset.json b/cli/tests/lsp/did_open_notification_asset.json new file mode 100644 index 0000000000..413353f298 --- /dev/null +++ b/cli/tests/lsp/did_open_notification_asset.json @@ -0,0 +1,12 @@ +{ + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "file:///a/file.ts", + "languageId": "typescript", + "version": 1, + "text": "console.log(Date.now());\n" + } + } +} diff --git a/cli/tests/lsp/hover_request_asset_01.json b/cli/tests/lsp/hover_request_asset_01.json new file mode 100644 index 0000000000..fb1c899a30 --- /dev/null +++ b/cli/tests/lsp/hover_request_asset_01.json @@ -0,0 +1,14 @@ +{ + "jsonrpc": "2.0", + "id": 4, + "method": "textDocument/hover", + "params": { + "textDocument": { + "uri": "file:///a/file.ts" + }, + "position": { + "line": 0, + "character": 12 + } + } +} diff --git a/cli/tests/lsp/hover_request_asset_02.json b/cli/tests/lsp/hover_request_asset_02.json new file mode 100644 index 0000000000..30f4047096 --- /dev/null +++ b/cli/tests/lsp/hover_request_asset_02.json @@ -0,0 +1,14 @@ +{ + "jsonrpc": "2.0", + "id": 4, + "method": "textDocument/hover", + "params": { + "textDocument": { + "uri": "deno:/asset//lib.es2015.symbol.wellknown.d.ts" + }, + "position": { + "line": 109, + "character": 13 + } + } +} diff --git a/cli/tests/lsp/virtual_text_document_request.json b/cli/tests/lsp/virtual_text_document_request.json new file mode 100644 index 0000000000..08ad7a3ca4 --- /dev/null +++ b/cli/tests/lsp/virtual_text_document_request.json @@ -0,0 +1,10 @@ +{ + "jsonrpc": "2.0", + "id": 2, + "method": "deno/virtualTextDocument", + "params": { + "textDocument": { + "uri": "deno:/asset//lib.es2015.symbol.wellknown.d.ts" + } + } +}