From f32eb525f3fa0828a23f589d765c267e3b2aea86 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Fri, 2 Sep 2016 12:50:15 -0400 Subject: Do not send push notifications for channels being actively viewed (#3931) --- api/status_test.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'api/status_test.go') diff --git a/api/status_test.go b/api/status_test.go index 451f39e14..a8292d323 100644 --- a/api/status_test.go +++ b/api/status_test.go @@ -151,3 +151,39 @@ func TestStatuses(t *testing.T) { t.Fatal("didn't get offline event") } } + +func TestSetActiveChannel(t *testing.T) { + th := Setup().InitBasic() + Client := th.BasicClient + + if _, err := Client.SetActiveChannel(th.BasicChannel.Id); err != nil { + t.Fatal(err) + } + + status, _ := GetStatus(th.BasicUser.Id) + if status.ActiveChannel != th.BasicChannel.Id { + t.Fatal("active channel should be set") + } + + if _, err := Client.SetActiveChannel(""); err != nil { + t.Fatal(err) + } + + status, _ = GetStatus(th.BasicUser.Id) + if status.ActiveChannel != "" { + t.Fatal("active channel should be blank") + } + + if _, err := Client.SetActiveChannel("123456789012345678901234567890"); err == nil { + t.Fatal("should have failed, id too long") + } + + if _, err := Client.UpdateLastViewedAt(th.BasicChannel.Id, true); err != nil { + t.Fatal(err) + } + + status, _ = GetStatus(th.BasicUser.Id) + if status.ActiveChannel != th.BasicChannel.Id { + t.Fatal("active channel should be set") + } +} -- cgit v1.2.3-1-g7c22