-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmatcher_test.go
45 lines (35 loc) · 1.25 KB
/
matcher_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
package go_gen_fsm
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
)
var _ = Describe("DelimiterMatcher", func() {
var (
subject NameMatcher
)
Context("Match", func() {
BeforeEach(func() {
subject = DelimiterMatcher{"_"}
})
DescribeTable("Matches with pattern StateName_EventName", func(name, stateExp, eventExp string) {
result, state, event := subject.Matches(name)
Expect(result).Should(Equal(true))
Expect(state).Should(Equal(State(stateExp)))
Expect(event).Should(Equal(Event(eventExp)))
}, Entry("Simple", "State_Event", "State", "Event"),
Entry("MultiWord", "StateWithMoreWords_EventWithMoreWords", "StateWithMoreWords", "EventWithMoreWords"),
Entry("EventWithLowerCaseLetter", "State_eventWithLowerCase", "State", "eventWithLowerCase"))
})
Context("Does Not Match", func() {
BeforeEach(func() {
subject = DelimiterMatcher{"_"}
})
DescribeTable("Does not match with pattern other than StateName_EventName", func(name string) {
result, _, _ := subject.Matches(name)
Expect(result).Should(Equal(false))
}, Entry("MultipleUnderscores", "State_Ev_ent"),
Entry("OtherSpecialCharacters", "State#Event"),
Entry("LowercaseState", "state_Event"))
})
})