From fe38d6d5bb36e18ddefbe490cc21f48f4f4c8d81 Mon Sep 17 00:00:00 2001 From: Gabin Aureche Date: Mon, 13 Mar 2017 13:25:08 +0100 Subject: Add pinned posts (#4217) --- api/channel_test.go | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) (limited to 'api/channel_test.go') diff --git a/api/channel_test.go b/api/channel_test.go index 93c79d416..08136bc35 100644 --- a/api/channel_test.go +++ b/api/channel_test.go @@ -926,8 +926,8 @@ func TestGetMoreChannelsPage(t *testing.T) { } else { channels := r.Data.(*model.ChannelList) - // 1 for BasicChannel, 2 for open channels created above - if len(*channels) != 3 { + // 1 for BasicChannel, 1 for PinnedPostChannel, 2 for open channels created above + if len(*channels) != 4 { t.Fatal("wrong length") } @@ -990,11 +990,11 @@ func TestGetChannelCounts(t *testing.T) { } else { counts := result.Data.(*model.ChannelCounts) - if len(counts.Counts) != 5 { + if len(counts.Counts) != 6 { t.Fatal("wrong number of channel counts") } - if len(counts.UpdateTimes) != 5 { + if len(counts.UpdateTimes) != 6 { t.Fatal("wrong number of channel update times") } @@ -1024,8 +1024,8 @@ func TestGetMyChannelMembers(t *testing.T) { } else { members := result.Data.(*model.ChannelMembers) - // town-square, off-topic, basic test channel, channel1, channel2 - if len(*members) != 5 { + // town-square, off-topic, basic test channel, pinned post channel, channel1, channel2 + if len(*members) != 6 { t.Fatal("wrong number of members", len(*members)) } } @@ -2117,3 +2117,24 @@ func TestUpdateChannelRoles(t *testing.T) { t.Fatal("Channel member should not be able to promote itself to channel admin:", meta) } } + +func TestGetPinnedPosts(t *testing.T) { + th := Setup().InitBasic() + Client := th.BasicClient + + post1 := th.BasicPost + r1 := Client.Must(Client.GetPinnedPosts(post1.ChannelId)).Data.(*model.PostList) + if len(r1.Order) != 0 { + t.Fatal("should not have gotten a pinned post") + } + + post2 := th.PinnedPost + r2 := Client.Must(Client.GetPinnedPosts(post2.ChannelId)).Data.(*model.PostList) + if len(r2.Order) == 0 { + t.Fatal("should have gotten a pinned post") + } + + if _, ok := r2.Posts[post2.Id]; !ok { + t.Fatal("missing pinned post") + } +} -- cgit v1.2.3-1-g7c22