diff options
Diffstat (limited to 'model/post_test.go')
-rw-r--r-- | model/post_test.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/model/post_test.go b/model/post_test.go index ced84f26b..846c8c775 100644 --- a/model/post_test.go +++ b/model/post_test.go @@ -123,3 +123,46 @@ func TestPostIsSystemMessage(t *testing.T) { t.Fatalf("TestPostIsSystemMessage failed, expected post2.IsSystemMessage() to be true") } } + +func TestPostSanitizeProps(t *testing.T) { + post1 := &Post{ + Message: "test", + } + + post1.SanitizeProps() + + if post1.Props[PROPS_ADD_CHANNEL_MEMBER] != nil { + t.Fatal("should be nil") + } + + post2 := &Post{ + Message: "test", + Props: StringInterface{ + PROPS_ADD_CHANNEL_MEMBER: "test", + }, + } + + post2.SanitizeProps() + + if post2.Props[PROPS_ADD_CHANNEL_MEMBER] != nil { + t.Fatal("should be nil") + } + + post3 := &Post{ + Message: "test", + Props: StringInterface{ + PROPS_ADD_CHANNEL_MEMBER: "no good", + "attachments": "good", + }, + } + + post3.SanitizeProps() + + if post3.Props[PROPS_ADD_CHANNEL_MEMBER] != nil { + t.Fatal("should be nil") + } + + if post3.Props["attachments"] == nil { + t.Fatal("should not be nil") + } +} |