forked from src-d/flamingo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api_test.go
70 lines (53 loc) · 1.24 KB
/
api_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
67
68
69
70
package flamingo
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestPolicies(t *testing.T) {
assert := assert.New(t)
p := IgnorePolicy()
assert.False(p.Reply)
p = ReplyPolicy("foo")
assert.True(p.Reply)
assert.Equal("foo", p.Message)
}
func TestButtonGroup(t *testing.T) {
assert := assert.New(t)
g := NewButtonGroup(
"foo",
NewButton("a", "a"),
NewPrimaryButton("b", "b"),
NewDangerButton("c", "c"),
)
assert.Equal("foo", g.ID())
assert.Equal(3, len(g.Items()))
assert.Equal(ButtonGroup, g.Type())
}
func TestImage(t *testing.T) {
assert := assert.New(t)
g := Image{}
assert.Equal("", g.ID())
assert.Equal(1, len(g.Items()))
assert.Equal(ImageGroup, g.Type())
}
func TestText(t *testing.T) {
assert := assert.New(t)
g := Text("fooooo")
assert.Equal("", g.ID())
assert.Equal(1, len(g.Items()))
assert.Equal(TextGroup, g.Type())
}
func TestTextFieldGroup(t *testing.T) {
assert := assert.New(t)
g := NewTextFieldGroup(
NewTextField("a", "a"),
NewTextField("b", "b"),
NewShortTextField("c", "c"),
)
assert.Equal("", g.ID())
assert.Equal(3, len(g.Items()))
assert.Equal(TextFieldGroup, g.Type())
}
func TestNewOutgoingMessage(t *testing.T) {
assert.Equal(t, "foo", NewOutgoingMessage("foo").Text)
}