summaryrefslogtreecommitdiffstats
path: root/app/command_join_test.go
diff options
context:
space:
mode:
authorJoramWilander <jwawilander@gmail.com>2018-06-27 16:56:50 -0400
committerJoramWilander <jwawilander@gmail.com>2018-06-27 16:56:50 -0400
commit88c5e469ca869d9e8ceadb0f2b03e86005102f24 (patch)
treebbb1b4cc1312879476f222940651e4d3e763da9e /app/command_join_test.go
parentd7976549a0b45a42c04ac043a15677b7ca1228e9 (diff)
parent437f9f5b64ddb4e1f84e6c4e993120d074001777 (diff)
downloadchat-88c5e469ca869d9e8ceadb0f2b03e86005102f24.tar.gz
chat-88c5e469ca869d9e8ceadb0f2b03e86005102f24.tar.bz2
chat-88c5e469ca869d9e8ceadb0f2b03e86005102f24.zip
Merge branch 'master' into plugins-2
Diffstat (limited to 'app/command_join_test.go')
-rw-r--r--app/command_join_test.go88
1 files changed, 88 insertions, 0 deletions
diff --git a/app/command_join_test.go b/app/command_join_test.go
new file mode 100644
index 000000000..77574217b
--- /dev/null
+++ b/app/command_join_test.go
@@ -0,0 +1,88 @@
+// Copyright (c) 2018-present Mattermost, Inc. All Rights Reserved.
+// See License.txt for license information.
+
+package app
+
+import (
+ "testing"
+ "github.com/mattermost/mattermost-server/model"
+ "github.com/nicksnyder/go-i18n/i18n"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestJoinCommandNoChannel(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ if testing.Short() {
+ t.SkipNow()
+ }
+
+ cmd := &JoinProvider{}
+ resp := cmd.DoCommand(th.App, &model.CommandArgs{
+ T: i18n.IdentityTfunc(),
+ UserId: th.BasicUser2.Id,
+ SiteURL: "http://test.url",
+ TeamId: th.BasicTeam.Id,
+ }, "asdsad")
+
+ assert.Equal(t, "api.command_join.list.app_error", resp.Text)
+}
+
+func TestJoinCommandForExistingChannel(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ if testing.Short() {
+ t.SkipNow()
+ }
+
+ channel2, _ := th.App.CreateChannel(&model.Channel{
+ DisplayName: "AA",
+ Name: "aa" + model.NewId() + "a",
+ Type: model.CHANNEL_OPEN,
+ TeamId: th.BasicTeam.Id,
+ CreatorId: th.BasicUser.Id,
+ }, false)
+
+
+ cmd := &JoinProvider{}
+ resp := cmd.DoCommand(th.App, &model.CommandArgs{
+ T: i18n.IdentityTfunc(),
+ UserId: th.BasicUser2.Id,
+ SiteURL: "http://test.url",
+ TeamId: th.BasicTeam.Id,
+ }, channel2.Name)
+
+ assert.Equal(t, "", resp.Text)
+ assert.Equal(t, "http://test.url/"+th.BasicTeam.Name+"/channels/"+channel2.Name, resp.GotoLocation)
+}
+
+func TestJoinCommandWithTilde(t *testing.T) {
+ th := Setup().InitBasic()
+ defer th.TearDown()
+
+ if testing.Short() {
+ t.SkipNow()
+ }
+
+ channel2, _ := th.App.CreateChannel(&model.Channel{
+ DisplayName: "AA",
+ Name: "aa" + model.NewId() + "a",
+ Type: model.CHANNEL_OPEN,
+ TeamId: th.BasicTeam.Id,
+ CreatorId: th.BasicUser.Id,
+ }, false)
+
+
+ cmd := &JoinProvider{}
+ resp := cmd.DoCommand(th.App, &model.CommandArgs{
+ T: i18n.IdentityTfunc(),
+ UserId: th.BasicUser2.Id,
+ SiteURL: "http://test.url",
+ TeamId: th.BasicTeam.Id,
+ }, "~"+channel2.Name)
+
+ assert.Equal(t, "", resp.Text)
+ assert.Equal(t, "http://test.url/"+th.BasicTeam.Name+"/channels/"+channel2.Name, resp.GotoLocation)
+}