-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage_test.go
79 lines (67 loc) · 2.44 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package main_test
import (
. "github.com/smousa/chatty"
"github.com/smousa/chatty/app"
"github.com/smousa/chatty/app/test"
"github.com/smousa/chatty/mocks"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Message", func() {
var (
t = GinkgoT()
controller *MessageController
input string
result *app.ChattyMessageInfo
m *mocks.URLReader
)
BeforeEach(func() {
t = GinkgoT()
m = &mocks.URLReader{}
controller = NewMessageController(svc)
controller.URLReader = m
})
JustBeforeEach(func() {
_, result = test.ParseMessageOK(t, ctx, svc, controller, &app.ParseMessagePayload{
Input: input,
})
})
Context("@chris you around?", func() {
BeforeEach(func() {
input = "@chris you around"
})
It("should show that chris was mentioned", func() {
Expect(result.Mentions).To(ConsistOf("chris"))
Expect(result.Emoticons).To(BeEmpty())
Expect(result.Links).To(BeEmpty())
})
})
Context("Olympics are starting soon; http://www.nbcolympics.com", func() {
BeforeEach(func() {
input = "Olympics are starting soon; http://www.nbcolympics.com"
m.On("PageTitle", "http://www.nbcolympics.com").Return("2016 Rio Olympic Games | NBC Olympics", nil)
})
It("should show the title and url of the link", func() {
Expect(result.Mentions).To(BeEmpty())
Expect(result.Emoticons).To(BeEmpty())
Expect(result.Links).To(ConsistOf(&app.ChattyLink{
URL: "http://www.nbcolympics.com",
Title: "2016 Rio Olympic Games | NBC Olympics",
}))
})
})
Context("@bob @john (success) such a cool feature; https://twitter.com/jdorfman/status/430511497475670016", func() {
BeforeEach(func() {
input = "@bob @john (success) such a cool feature; https://twitter.com/jdorfman/status/430511497475670016"
m.On("PageTitle", "https://twitter.com/jdorfman/status/430511497475670016").Return("Justin Dorfman on Twitter: "nice @littlebigdetail from @HipChat (shows hex colors when pasted in chat). http://t.co/7cI6Gjy5pq"", nil)
})
It("should show bob, john, success, and the url", func() {
Expect(result.Mentions).To(ConsistOf("bob", "john"))
Expect(result.Emoticons).To(ConsistOf("success"))
Expect(result.Links).To(ConsistOf(&app.ChattyLink{
URL: "https://twitter.com/jdorfman/status/430511497475670016",
Title: "Justin Dorfman on Twitter: "nice @littlebigdetail from @HipChat (shows hex colors when pasted in chat). http://t.co/7cI6Gjy5pq"",
}))
})
})
})