diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2024-08-06 16:30:34 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-06 16:30:34 +0100 |
commit | 9a83efa04b6e733ca0fdbf9e780c4b77f0d9f4be (patch) | |
tree | 262621aedc6b78c0acc43371007a8a28cad74897 /tests/integration/lsp_tests.rs | |
parent | b3f1f3ba04e51554ab59d6255bf34a79a9c42bd0 (diff) |
feat(lsp): node specifier completions (#24904)
Diffstat (limited to 'tests/integration/lsp_tests.rs')
-rw-r--r-- | tests/integration/lsp_tests.rs | 107 |
1 files changed, 106 insertions, 1 deletions
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs index cbc175ec6..d89061683 100644 --- a/tests/integration/lsp_tests.rs +++ b/tests/integration/lsp_tests.rs @@ -7499,6 +7499,111 @@ fn lsp_npm_completions_auto_import_and_quick_fix_no_import_map() { } #[test] +fn lsp_completions_node_specifier() { + let context = TestContextBuilder::new().use_temp_cwd().build(); + let temp_dir = context.temp_dir(); + let mut client = context.new_lsp_command().build(); + client.initialize_default(); + client.did_open(json!({ + "textDocument": { + "uri": temp_dir.uri().join("file.ts").unwrap(), + "languageId": "typescript", + "version": 1, + "text": "import fs from \"node:as\";\n", + }, + })); + let list = client.get_completion_list( + temp_dir.uri().join("file.ts").unwrap(), + (0, 23), + json!({ + "triggerKind": 2, + "triggerCharacter": ".", + }), + ); + assert!(!list.is_incomplete); + assert_eq!( + list + .items + .iter() + .map(|i| i.label.as_str()) + .collect::<Vec<_>>(), + vec![ + "node:assert", + "node:assert/strict", + "node:async_hooks", + "node:buffer", + "node:child_process", + "node:cluster", + "node:console", + "node:constants", + "node:crypto", + "node:dgram", + "node:diagnostics_channel", + "node:dns", + "node:dns/promises", + "node:domain", + "node:events", + "node:fs", + "node:fs/promises", + "node:http", + "node:http2", + "node:https", + "node:module", + "node:net", + "node:os", + "node:path", + "node:path/posix", + "node:path/win32", + "node:perf_hooks", + "node:process", + "node:punycode", + "node:querystring", + "node:repl", + "node:readline", + "node:readline/promises", + "node:stream", + "node:stream/consumers", + "node:stream/promises", + "node:stream/web", + "node:string_decoder", + "node:sys", + "node:test", + "node:timers", + "node:timers/promises", + "node:tls", + "node:tty", + "node:url", + "node:util", + "node:util/types", + "node:v8", + "node:vm", + "node:worker_threads", + "node:zlib", + ], + ); + for item in &list.items { + let specifier = item.label.as_str(); + assert_eq!( + json!(item), + json!({ + "label": specifier, + "kind": 17, + "detail": "(node)", + "textEdit": { + "range": { + "start": { "line": 0, "character": 16 }, + "end": { "line": 0, "character": 23 }, + }, + "newText": specifier, + }, + "commitCharacters": ["\"", "'"], + }), + ); + } + client.shutdown(); +} + +#[test] fn lsp_infer_return_type() { let context = TestContextBuilder::new().use_temp_cwd().build(); let temp_dir = context.temp_dir(); @@ -8614,7 +8719,7 @@ fn lsp_npm_specifier_unopened_file() { } #[test] -fn lsp_completions_node_specifier() { +fn lsp_completions_node_builtin() { let context = TestContextBuilder::new() .use_http_server() .use_temp_cwd() |