github.com/gigforks/mattermost-server@v4.9.1-0.20180619094218-800d97fa55d0+incompatible/api/command_expand_collapse_test.go (about) 1 // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package api 5 6 import ( 7 "testing" 8 "time" 9 10 "github.com/mattermost/mattermost-server/model" 11 ) 12 13 func TestExpandCommand(t *testing.T) { 14 th := Setup().InitBasic() 15 defer th.TearDown() 16 17 Client := th.BasicClient 18 channel := th.BasicChannel 19 20 r1 := Client.Must(Client.Command(channel.Id, "/expand")).Data.(*model.CommandResponse) 21 if r1 == nil { 22 t.Fatal("Command failed to execute") 23 } 24 25 time.Sleep(100 * time.Millisecond) 26 27 p1 := Client.Must(Client.GetPreference(model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, model.PREFERENCE_NAME_COLLAPSE_SETTING)).Data.(*model.Preference) 28 if p1.Value != "false" { 29 t.Fatal("preference not updated correctly") 30 } 31 } 32 33 func TestCollapseCommand(t *testing.T) { 34 th := Setup().InitBasic() 35 defer th.TearDown() 36 37 Client := th.BasicClient 38 channel := th.BasicChannel 39 40 r1 := Client.Must(Client.Command(channel.Id, "/collapse")).Data.(*model.CommandResponse) 41 if r1 == nil { 42 t.Fatal("Command failed to execute") 43 } 44 45 time.Sleep(100 * time.Millisecond) 46 47 p1 := Client.Must(Client.GetPreference(model.PREFERENCE_CATEGORY_DISPLAY_SETTINGS, model.PREFERENCE_NAME_COLLAPSE_SETTING)).Data.(*model.Preference) 48 if p1.Value != "true" { 49 t.Fatal("preference not updated correctly") 50 } 51 }