Skip to content

Commit

Permalink
test(lsp): make lsp_completions_auto_import more robust (denoland#18482)
Browse files Browse the repository at this point in the history
A completely unrelated change in
denoland#18286 threw of this test.

These changes make it more robust and easier to update in such cases.
  • Loading branch information
bartlomieju committed Mar 28, 2023
1 parent c5302a0 commit ceab7a8
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions cli/tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:https:///a/file.ts",
"position": 12,
"name": "foo",
"source": "./b.ts",
"data": {
"exportName": "foo",
"exportMapKey": "foo|6843|file:https:///a/b",
"moduleSpecifier": "./b.ts",
"fileName": "file:https:///a/b.ts"
},
"useCodeSnippet": false
}
let req = json!({
"label": "foo",
"kind": 6,
"sortText": "￿16",
"commitCharacters": [
".",
",",
";",
"("
],
"data": {
"tsc": {
"specifier": "file:https:///a/file.ts",
"position": 12,
"name": "foo",
"source": "./b.ts",
"data": {
"exportName": "foo",
"exportMapKey": "foo|6843|file:https:///a/b",
"moduleSpecifier": "./b.ts",
"fileName": "file:https:///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!({
Expand Down

0 comments on commit ceab7a8

Please sign in to comment.