summaryrefslogtreecommitdiffstats
path: root/model/slack_attachment_test.go
blob: 2ba32baf2454eb3e639f8d105502689f0c520b9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package model

import (
	"testing"
)

func TestExpandAnnouncement(t *testing.T) {
	if ExpandAnnouncement("<!channel> foo <!channel>") != "@channel foo @channel" {
		t.Fail()
	}
}

func TestProcessSlackAnnouncement(t *testing.T) {
	attachments := []*SlackAttachment{
		{
			Pretext: "<!channel> pretext",
			Text:    "<!channel> text",
			Title:   "<!channel> title",
			Fields: []*SlackAttachmentField{
				{
					Title: "foo",
					Value: "<!channel> bar",
					Short: true,
				}, nil,
			},
		}, nil,
	}
	attachments = ProcessSlackAttachments(attachments)
	if len(attachments) != 1 || len(attachments[0].Fields) != 1 {
		t.Fail()
	}
	if attachments[0].Pretext != "@channel pretext" ||
		attachments[0].Text != "@channel text" ||
		attachments[0].Title != "@channel title" ||
		attachments[0].Fields[0].Value != "@channel bar" {
		t.Fail()
	}
}