mirror of
https://github.com/laravel-ls/protocol.git
synced 2026-06-18 13:00:03 +02:00
add tests
This commit is contained in:
parent
5049160990
commit
be37cd5a53
20 changed files with 755 additions and 1 deletions
29
workspace_test.go
Normal file
29
workspace_test.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package protocol_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/laravel-ls/protocol"
|
||||
)
|
||||
|
||||
func Test_Workspace_StructsUnmarshalValidJSON(t *testing.T) {
|
||||
var ws protocol.WorkspaceEdit
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"changes":{"file:///tmp/main.go":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":0}},"newText":"package main\n"}]},
|
||||
"changeAnnotations":{"a1":{"label":"Add package declaration","description":"Needed for file header","needsConfirmation":false}}
|
||||
}`), &ws); err != nil {
|
||||
t.Fatalf("unmarshal WorkspaceEdit failed: %v", err)
|
||||
}
|
||||
if len(ws.Changes) != 1 || len(ws.ChangeAnnotations) != 1 {
|
||||
t.Fatalf("unexpected WorkspaceEdit: %+v", ws)
|
||||
}
|
||||
|
||||
var folder protocol.WorkspaceFolder
|
||||
if err := json.Unmarshal([]byte(`{"uri":"file:///workspace","name":"workspace"}`), &folder); err != nil {
|
||||
t.Fatalf("unmarshal WorkspaceFolder failed: %v", err)
|
||||
}
|
||||
if folder.Name != "workspace" {
|
||||
t.Fatalf("unexpected WorkspaceFolder: %+v", folder)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue