-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreporters_test.go
59 lines (44 loc) · 1.63 KB
/
reporters_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
package golden_test
import (
"github.com/franiglesias/golden"
"github.com/stretchr/testify/assert"
"testing"
)
func TestCharDiffReporter(t *testing.T) {
reporter := golden.CharDiffReporter{}
t.Run("show no differences", func(t *testing.T) {
result := reporter.Differences("Same content", "Same content")
assert.Equal(t, "No differences found.", result)
})
t.Run("show char differences", func(t *testing.T) {
result := reporter.Differences("Wanted this.", "Gotten that.")
assert.Contains(t, result, "Differences found:")
assert.Contains(t, result, "(~~Wanted this~~)(++Gotten that++)")
})
}
func TestLineDiffReporter(t *testing.T) {
reporter := golden.LineDiffReporter{}
t.Run("show no differences", func(t *testing.T) {
result := reporter.Differences("Same content", "Same content")
assert.Equal(t, "No differences found.", result)
})
t.Run("show char differences", func(t *testing.T) {
result := reporter.Differences("Wanted this.", "Gotten that.")
assert.Contains(t, result, "Differences found:")
assert.Contains(t, result, "-Wanted this.")
assert.Contains(t, result, "+Gotten that.")
})
}
func TestBetterDiffReporter(t *testing.T) {
reporter := golden.NewBetterDiffReporter()
t.Run("show no differences", func(t *testing.T) {
result := reporter.Differences("Same content", "Same content")
assert.Equal(t, "No differences found.", result)
})
t.Run("show differences", func(t *testing.T) {
result := reporter.Differences("Wanted this.", "Gotten that.")
assert.Contains(t, result, "Differences found:")
assert.Contains(t, result, "- Wanted this.")
assert.Contains(t, result, "+ Gotten that.")
})
}