vendor tsgo
This commit is contained in:
84
tools/tsgo/internal/lsp/lsproto/lsp_test.go
Normal file
84
tools/tsgo/internal/lsp/lsproto/lsp_test.go
Normal file
@@ -0,0 +1,84 @@
|
||||
package lsproto
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/microsoft/typescript-go/internal/json"
|
||||
"gotest.tools/v3/assert"
|
||||
)
|
||||
|
||||
func TestUnmarshalCompletionItem(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
const message = `{
|
||||
"label": "pageXOffset",
|
||||
"insertTextFormat": 1,
|
||||
"textEdit": {
|
||||
"newText": "pageXOffset",
|
||||
"insert": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"character": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"character": 4
|
||||
}
|
||||
},
|
||||
"replace": {
|
||||
"start": {
|
||||
"line": 4,
|
||||
"character": 0
|
||||
},
|
||||
"end": {
|
||||
"line": 4,
|
||||
"character": 4
|
||||
}
|
||||
}
|
||||
},
|
||||
"kind": 6,
|
||||
"sortText": "15",
|
||||
"commitCharacters": [
|
||||
".",
|
||||
",",
|
||||
";"
|
||||
]
|
||||
}`
|
||||
|
||||
var result CompletionItem
|
||||
err := json.Unmarshal([]byte(message), &result)
|
||||
assert.NilError(t, err)
|
||||
|
||||
assert.DeepEqual(t, result, CompletionItem{
|
||||
Label: "pageXOffset",
|
||||
InsertTextFormat: new(InsertTextFormatPlainText),
|
||||
TextEdit: &TextEditOrInsertReplaceEdit{
|
||||
InsertReplaceEdit: &InsertReplaceEdit{
|
||||
NewText: "pageXOffset",
|
||||
Insert: Range{
|
||||
Start: Position{
|
||||
Line: 4,
|
||||
Character: 0,
|
||||
},
|
||||
End: Position{
|
||||
Line: 4,
|
||||
Character: 4,
|
||||
},
|
||||
},
|
||||
Replace: Range{
|
||||
Start: Position{
|
||||
Line: 4,
|
||||
Character: 0,
|
||||
},
|
||||
End: Position{
|
||||
Line: 4,
|
||||
Character: 4,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Kind: new(CompletionItemKindVariable),
|
||||
SortText: new("15"),
|
||||
CommitCharacters: new([]string{".", ",", ";"}),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user