forked from slack-go/slack
-
Notifications
You must be signed in to change notification settings - Fork 4
/
block_object_test.go
66 lines (42 loc) · 1.99 KB
/
block_object_test.go
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package slack
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestNewImageBlockObject(t *testing.T) {
imageObject := NewImageBlockElement("https://api.slack.com/img/blocks/bkb_template_images/beagle.png", "Beagle")
assert.Equal(t, string(imageObject.Type), "image")
assert.Equal(t, imageObject.AltText, "Beagle")
assert.Contains(t, imageObject.ImageURL, "beagle.png")
}
func TestNewTextBlockObject(t *testing.T) {
textObject := NewTextBlockObject("plain_text", "test", true, false)
assert.Equal(t, textObject.Type, "plain_text")
assert.Equal(t, textObject.Text, "test")
assert.True(t, textObject.Emoji, "Emoji property should be true")
assert.False(t, textObject.Verbatim, "Verbatim should be false")
}
func TestNewConfirmationBlockObject(t *testing.T) {
titleObj := NewTextBlockObject("plain_text", "testTitle", false, false)
textObj := NewTextBlockObject("plain_text", "testText", false, false)
confirmObj := NewTextBlockObject("plain_text", "testConfirm", false, false)
confirmation := NewConfirmationBlockObject(titleObj, textObj, confirmObj, nil)
assert.Equal(t, confirmation.Title.Text, "testTitle")
assert.Equal(t, confirmation.Text.Text, "testText")
assert.Equal(t, confirmation.Confirm.Text, "testConfirm")
assert.Nil(t, confirmation.Deny, "Deny should be nil")
}
func TestNewOptionBlockObject(t *testing.T) {
valTextObj := NewTextBlockObject("plain_text", "testText", false, false)
optObj := NewOptionBlockObject("testOpt", valTextObj)
assert.Equal(t, optObj.Text.Text, "testText")
assert.Equal(t, optObj.Value, "testOpt")
}
func TestNewOptionGroupBlockElement(t *testing.T) {
labelObj := NewTextBlockObject("plain_text", "testLabel", false, false)
valTextObj := NewTextBlockObject("plain_text", "testText", false, false)
optObj := NewOptionBlockObject("testOpt", valTextObj)
optGroup := NewOptionGroupBlockElement(labelObj, optObj)
assert.Equal(t, optGroup.Label.Text, "testLabel")
assert.Len(t, optGroup.Options, 1, "Options should contain one element")
}