mirror of
https://github.com/laravel-ls/protocol.git
synced 2026-06-17 12:30:04 +02:00
add tests
This commit is contained in:
parent
5049160990
commit
be37cd5a53
20 changed files with 755 additions and 1 deletions
30
document_code_action_test.go
Normal file
30
document_code_action_test.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package protocol_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/laravel-ls/protocol"
|
||||
)
|
||||
|
||||
func Test_DocumentCodeAction_StructsUnmarshalValidJSON(t *testing.T) {
|
||||
var params protocol.CodeActionParams
|
||||
if err := json.Unmarshal([]byte(`{
|
||||
"textDocument":{"uri":"file:///tmp/main.go"},
|
||||
"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":4}},
|
||||
"context":{"diagnostics":[{"range":{"start":{"line":1,"character":0},"end":{"line":1,"character":4}},"message":"problem"}],"only":["quickfix"],"triggerKind":1}
|
||||
}`), ¶ms); err != nil {
|
||||
t.Fatalf("unmarshal CodeActionParams failed: %v", err)
|
||||
}
|
||||
if len(params.Context.Diagnostics) != 1 {
|
||||
t.Fatalf("unexpected CodeActionParams diagnostics: %+v", params.Context.Diagnostics)
|
||||
}
|
||||
|
||||
var action protocol.CodeAction
|
||||
if err := json.Unmarshal([]byte(`{"title":"Fix issue","kind":"quickfix","isPreferred":true,"disabled":{"reason":"not applicable"}}`), &action); err != nil {
|
||||
t.Fatalf("unmarshal CodeAction failed: %v", err)
|
||||
}
|
||||
if action.Disabled == nil || action.Disabled.Reason != "not applicable" {
|
||||
t.Fatalf("unexpected CodeAction disabled state: %+v", action.Disabled)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue