From da7b522b934b433725aa0a57c1ef6e3e1dac16e1 Mon Sep 17 00:00:00 2001 From: Duologic Date: Thu, 7 Mar 2024 14:41:00 +0100 Subject: [PATCH] test(completion): quote labels --- pkg/server/completion_test.go | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/pkg/server/completion_test.go b/pkg/server/completion_test.go index 92855d7..fa85eb9 100644 --- a/pkg/server/completion_test.go +++ b/pkg/server/completion_test.go @@ -586,6 +586,83 @@ func TestCompletion(t *testing.T) { }, }, }, + { + name: "quote label", + filename: "testdata/quote_label.jsonnet", + replaceString: "lib", + replaceByString: "lib.", + expected: protocol.CompletionList{ + IsIncomplete: false, + Items: []protocol.CompletionItem{ + { + Label: "1num", + Kind: protocol.FieldCompletion, + Detail: "lib['1num']", + InsertText: "['1num']", + LabelDetails: protocol.CompletionItemLabelDetails{ + Description: "string", + }, + TextEdit: &protocol.TextEdit{ + Range: protocol.Range{ + Start: protocol.Position{ + Line: 0, + Character: 9, + }, + End: protocol.Position{ + Line: 0, + Character: 10, + }, + }, + NewText: "['1num']", + }, + }, + { + Label: "abc#func", + Kind: protocol.FunctionCompletion, + Detail: "lib['abc#func'](param)", + InsertText: "['abc#func'](param)", + LabelDetails: protocol.CompletionItemLabelDetails{ + Description: "function", + }, + TextEdit: &protocol.TextEdit{ + Range: protocol.Range{ + Start: protocol.Position{ + Line: 0, + Character: 9, + }, + End: protocol.Position{ + Line: 0, + Character: 10, + }, + }, + NewText: "['abc#func'](param)", + }, + }, + { + Label: "abc#var", + Kind: protocol.FieldCompletion, + Detail: "lib['abc#var']", + InsertText: "['abc#var']", + LabelDetails: protocol.CompletionItemLabelDetails{ + Description: "string", + }, + TextEdit: &protocol.TextEdit{ + Range: protocol.Range{ + Start: protocol.Position{ + Line: 0, + Character: 9, + }, + End: protocol.Position{ + Line: 0, + Character: 10, + }, + }, + NewText: "['abc#var']", + }, + }, + }, + }, + }, } for _, tc := range testCases { t.Run(tc.name, func(t *testing.T) {