Skip to content

Commit b898846

Browse files
committed
* update textDocument/completion tests to reflect changes in completion behavior after bug fix
** add a test that tests that record fields aren't suggested on completion ** update older completion tests to reflect that now proper context is used for completion
1 parent f512856 commit b898846

File tree

1 file changed

+30
-16
lines changed

1 file changed

+30
-16
lines changed

ocaml-lsp-server/test/e2e/__tests__/textDocument-completion.test.ts

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ describe_opt("textDocument/completion", () => {
250250
expect(items_top5).toMatchInlineSnapshot(`
251251
Array [
252252
Object {
253-
"label": "()",
253+
"label": "somenum",
254254
"textEdit": Object {
255-
"newText": "()",
255+
"newText": "somenum",
256256
"range": Object {
257257
"end": Object {
258258
"character": 12,
@@ -266,9 +266,9 @@ describe_opt("textDocument/completion", () => {
266266
},
267267
},
268268
Object {
269-
"label": "::",
269+
"label": "x",
270270
"textEdit": Object {
271-
"newText": "::",
271+
"newText": "x",
272272
"range": Object {
273273
"end": Object {
274274
"character": 12,
@@ -282,9 +282,9 @@ describe_opt("textDocument/completion", () => {
282282
},
283283
},
284284
Object {
285-
"label": "Assert_failure",
285+
"label": "y",
286286
"textEdit": Object {
287-
"newText": "Assert_failure",
287+
"newText": "y",
288288
"range": Object {
289289
"end": Object {
290290
"character": 12,
@@ -298,9 +298,9 @@ describe_opt("textDocument/completion", () => {
298298
},
299299
},
300300
Object {
301-
"label": "Division_by_zero",
301+
"label": "max_int",
302302
"textEdit": Object {
303-
"newText": "Division_by_zero",
303+
"newText": "max_int",
304304
"range": Object {
305305
"end": Object {
306306
"character": 12,
@@ -314,9 +314,9 @@ describe_opt("textDocument/completion", () => {
314314
},
315315
},
316316
Object {
317-
"label": "End_of_file",
317+
"label": "min_int",
318318
"textEdit": Object {
319-
"newText": "End_of_file",
319+
"newText": "min_int",
320320
"range": Object {
321321
"end": Object {
322322
"character": 12,
@@ -432,33 +432,33 @@ describe_opt("textDocument/completion", () => {
432432
},
433433
},
434434
{
435-
label: "ListLabels.t",
435+
label: "ListLabels.append",
436436
textEdit: {
437437
range: {
438438
start: { line: 0, character: 8 },
439439
end: { line: 0, character: 10 },
440440
},
441-
newText: "ListLabels.t",
441+
newText: "ListLabels.append",
442442
},
443443
},
444444
{
445-
label: "ListLabels.append",
445+
label: "ListLabels.assoc",
446446
textEdit: {
447447
range: {
448448
start: { line: 0, character: 8 },
449449
end: { line: 0, character: 10 },
450450
},
451-
newText: "ListLabels.append",
451+
newText: "ListLabels.assoc",
452452
},
453453
},
454454
{
455-
label: "ListLabels.assoc",
455+
label: "ListLabels.assoc_opt",
456456
textEdit: {
457457
range: {
458458
start: { line: 0, character: 8 },
459459
end: { line: 0, character: 10 },
460460
},
461-
newText: "ListLabels.assoc",
461+
newText: "ListLabels.assoc_opt",
462462
},
463463
},
464464
]);
@@ -563,4 +563,18 @@ describe_opt("textDocument/completion", () => {
563563
]
564564
`);
565565
});
566+
567+
it("completion doesn't autocomplete record fields", async () => {
568+
openDocument(outdent`
569+
type r = {
570+
x: int;
571+
y: string
572+
}
573+
574+
let _ =
575+
`);
576+
577+
let items: Array<any> = await queryCompletion(Types.Position.create(5, 8));
578+
expect(items.filter(compl => compl.label === "x" || compl.label === "y")).toHaveLength(0);
579+
})
566580
});

0 commit comments

Comments
 (0)