-
Notifications
You must be signed in to change notification settings - Fork 2
/
hook_test.go
61 lines (58 loc) · 972 Bytes
/
hook_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
package graterm
import (
"github.com/stretchr/testify/require"
"testing"
)
func Test_Hook_String(t *testing.T) {
type fields struct {
hook *Hook
}
tests := []struct {
name string
fields fields
want string
}{
{
name: "nil_struct",
fields: fields{
hook: nil,
},
want: `<nil>`,
},
{
name: "empty_non-nil_struct",
fields: fields{
hook: &Hook{},
},
want: `nameless component (order: 0)`,
},
{
name: "nameless_hook",
fields: fields{
hook: &Hook{
order: 3,
name: " ",
},
},
want: `nameless component (order: 3)`,
},
{
name: "hook_with_a_name",
fields: fields{
hook: &Hook{
order: 777,
name: "some random name",
},
},
want: `component: "some random name" (order: 777)`,
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
got := tt.fields.hook.String()
require.Equal(t, tt.want, got)
})
}
}