-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions_test.go
43 lines (37 loc) · 1.01 KB
/
options_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
package golden
import (
"github.com/stretchr/testify/assert"
"testing"
)
func TestOptions(t *testing.T) {
t.Run("should configure snapshot", func(t *testing.T) {
c := Config{name: ""}
option := Snapshot("a_name")
option(&c)
assert.Equal(t, "a_name", c.name)
})
t.Run("should configure approval mode", func(t *testing.T) {
c := Config{approve: false}
option := WaitApproval()
option(&c)
assert.True(t, c.approve)
})
t.Run("should configure snapshot folder", func(t *testing.T) {
c := Config{folder: "testdata"}
option := Folder("a_folder")
option(&c)
assert.Equal(t, "a_folder", c.folder)
})
t.Run("should configure extension for snapshot", func(t *testing.T) {
c := Config{ext: ".snap"}
option := Extension(".other")
option(&c)
assert.Equal(t, ".other", c.ext)
})
t.Run("should configure reporter", func(t *testing.T) {
c := Config{reporter: NewLineDiffReporter()}
option := Reporter(NewBetterDiffReporter())
option(&c)
assert.IsType(t, BetterDiffReporter{}, c.reporter)
})
}