-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmessage_test.go
51 lines (46 loc) · 1.38 KB
/
message_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
package i3status_test
import (
"github.com/ghedamat/go-i3status/i3status"
. "github.com/smartystreets/goconvey/convey"
"testing"
)
var testMsg = i3status.Message{
FullText: "fullMsg",
ShortText: "shortMsg",
Color: "#ff00ff",
MinWidth: 200,
Align: "center",
Name: "testblock",
Instance: "first",
Urgent: true,
Separator: true,
SeparatorBlockWidth: 20,
}
func TestHasMessageType(t *testing.T) {
Convey("The message struct exists", t, func() {
So(testMsg.FullText, ShouldEqual, "fullMsg")
})
}
func TestConvertMessageToJson(t *testing.T) {
Convey("Given a Message", t, func() {
msg := i3status.Message{FullText: "fullMsg"}
Convey("When a message is converted to json", func() {
json := msg.ToJson()
Convey("valid json is produced", func() {
res := `{"full_text":"fullMsg","short_text":"","color":"","min_width":0,"align":"","name":"","instance":"","urgent":false,"separator":false,"separator_block_width":0}`
So(json, ShouldEqual, res)
})
})
})
}
func TestMessageConstructor(t *testing.T) {
Convey("Given the Message Constructor", t, func() {
Convey("When a message is created", func() {
msg := i3status.NewMessage()
Convey("it has sane defaults", func() {
So(msg.Separator, ShouldEqual, true)
So(msg.Align, ShouldEqual, "left")
})
})
})
}