diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2023-03-28 23:58:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-28 23:58:12 +0200 |
commit | ceab7a8d2378eca85b87e5a1fa2882b328467bfc (patch) | |
tree | ea8a34b3ae4fc48fd32efcd84bb10f93061dc1da | |
parent | c5302a0587bfdc8a78e8edf7429772f471c47304 (diff) |
test(lsp): make lsp_completions_auto_import more robust (#18482)
A completely unrelated change in
https://github.com/denoland/deno/pull/18286 threw of this test.
These changes make it more robust and easier to update in such cases.
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 60 |
1 files changed, 30 insertions, 30 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 2f14e589d..11800c2f7 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -4402,40 +4402,40 @@ fn lsp_completions_auto_import() { json!({ "triggerKind": 1 }), ); assert!(!list.is_incomplete); - if !list.items.iter().any(|item| item.label == "foo") { + let item = list.items.iter().find(|item| item.label == "foo"); + if item.is_none() { panic!("completions items missing 'foo' symbol"); } - // the request here is one of the items in `list` - let res = client.write_request( - "completionItem/resolve", - json!({ - "label": "foo", - "kind": 6, - "sortText": "16", - "commitCharacters": [ - ".", - ",", - ";", - "(" - ], - "data": { - "tsc": { - "specifier": "file:///a/file.ts", - "position": 12, - "name": "foo", - "source": "./b.ts", - "data": { - "exportName": "foo", - "exportMapKey": "foo|6843|file:///a/b", - "moduleSpecifier": "./b.ts", - "fileName": "file:///a/b.ts" - }, - "useCodeSnippet": false - } + let req = json!({ + "label": "foo", + "kind": 6, + "sortText": "16", + "commitCharacters": [ + ".", + ",", + ";", + "(" + ], + "data": { + "tsc": { + "specifier": "file:///a/file.ts", + "position": 12, + "name": "foo", + "source": "./b.ts", + "data": { + "exportName": "foo", + "exportMapKey": "foo|6843|file:///a/b", + "moduleSpecifier": "./b.ts", + "fileName": "file:///a/b.ts" + }, + "useCodeSnippet": false } - }), - ); + } + }); + assert_eq!(serde_json::to_value(item.unwrap()).unwrap(), req); + + let res = client.write_request("completionItem/resolve", req); assert_eq!( res, json!({ |