mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
* PLT-5860 Updated copyright date in about modal * PLT-5860 Updated copyright notice in JSX files * PLT-5860 Updated copyright notice in go files * Fixed misc copyright dates * Fixed component snapshots
57 lines
1.3 KiB
Go
57 lines
1.3 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See License.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestWebSocketEvent(t *testing.T) {
|
|
m := NewWebSocketEvent("some_event", NewId(), NewId(), NewId(), nil)
|
|
m.Add("RootId", NewId())
|
|
json := m.ToJson()
|
|
result := WebSocketEventFromJson(strings.NewReader(json))
|
|
|
|
badresult := WebSocketEventFromJson(strings.NewReader("junk"))
|
|
if badresult != nil {
|
|
t.Fatal("should not have parsed")
|
|
}
|
|
|
|
if !m.IsValid() {
|
|
t.Fatal("should be valid")
|
|
}
|
|
|
|
if m.Broadcast.TeamId != result.Broadcast.TeamId {
|
|
t.Fatal("Ids do not match")
|
|
}
|
|
|
|
if m.Data["RootId"] != result.Data["RootId"] {
|
|
t.Fatal("Ids do not match")
|
|
}
|
|
}
|
|
|
|
func TestWebSocketResponse(t *testing.T) {
|
|
m := NewWebSocketResponse("OK", 1, map[string]interface{}{})
|
|
e := NewWebSocketError(1, &AppError{})
|
|
m.Add("RootId", NewId())
|
|
json := m.ToJson()
|
|
result := WebSocketResponseFromJson(strings.NewReader(json))
|
|
json2 := e.ToJson()
|
|
WebSocketResponseFromJson(strings.NewReader(json2))
|
|
|
|
badresult := WebSocketResponseFromJson(strings.NewReader("junk"))
|
|
if badresult != nil {
|
|
t.Fatal("should not have parsed")
|
|
}
|
|
|
|
if !m.IsValid() {
|
|
t.Fatal("should be valid")
|
|
}
|
|
|
|
if m.Data["RootId"] != result.Data["RootId"] {
|
|
t.Fatal("Ids do not match")
|
|
}
|
|
}
|