-
Notifications
You must be signed in to change notification settings - Fork 10
/
immutableAct_test.go
47 lines (38 loc) · 1.17 KB
/
immutableAct_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
package examples_test
import (
"strings"
"testing"
"go.llib.dev/testcase"
"go.llib.dev/testcase/docs/examples"
)
func TestImmutableAct(t *testing.T) {
s := testcase.NewSpec(t)
myStruct := testcase.Let(s, func(t *testcase.T) *examples.MyStruct {
return &examples.MyStruct{}
})
s.Describe(`#Shrug`, func(s *testcase.Spec) {
const shrugEmoji = `¯\_(ツ)_/¯`
var (
message = testcase.Let(s, func(t *testcase.T) string { return t.Random.String() })
subject = func(t *testcase.T) string {
return myStruct.Get(t).Shrug(message.Get(t))
}
)
s.When(`message doesn't have shrug in the ending`, func(s *testcase.Spec) {
s.Before(func(t *testcase.T) {
t.Must.Contain(subject(t), shrugEmoji)
})
s.Then(`it will append shrug emoji to this`, func(t *testcase.T) {
t.Must.True(strings.HasSuffix(subject(t), shrugEmoji))
})
})
s.When(`shrug part of the input message`, func(s *testcase.Spec) {
message.Let(s, func(t *testcase.T) string {
return t.Random.String() + shrugEmoji
})
s.Then(`it will not append any more shrug emoji to the end of the message`, func(t *testcase.T) {
t.Must.Equal(message.Get(t), subject(t))
})
})
})
}