-
Notifications
You must be signed in to change notification settings - Fork 1
/
paragraph_test.go
69 lines (60 loc) · 1.73 KB
/
paragraph_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
62
63
64
65
66
67
68
69
package goey
import (
"math/rand"
"reflect"
"testing"
"testing/quick"
"bitbucket.org/rj/goey/base"
)
func paragraphValues(values []reflect.Value, rand *rand.Rand) {
// Get a string
labelValues(values, rand)
// Create a random alignment
values[1] = reflect.ValueOf(TextAlignment(rand.Uint64() % 4))
}
func TestParagraphMount(t *testing.T) {
testingMountWidgets(t,
&P{Text: "A", Align: JustifyLeft},
&P{Text: "B", Align: JustifyRight},
&P{Text: "C", Align: JustifyCenter},
&P{Text: "D", Align: JustifyFull},
&P{Text: "", Align: JustifyLeft},
&P{Text: "ABCD\nEFGH", Align: JustifyLeft},
)
t.Run("QuickCheck", func(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode")
}
f := func(text string, align TextAlignment) bool {
return testingMountWidget(t, &P{Text: text, Align: align})
}
if err := quick.Check(f, &quick.Config{Values: paragraphValues}); err != nil {
t.Errorf("quick: %s", err)
}
})
}
func TestParagraphClose(t *testing.T) {
testingCloseWidgets(t,
&P{Text: "A", Align: JustifyLeft},
&P{Text: "B", Align: JustifyRight},
&P{Text: "C", Align: JustifyCenter},
&P{Text: "D", Align: JustifyFull},
)
}
func TestParagraphProps(t *testing.T) {
testingUpdateWidgets(t, []base.Widget{
&P{Text: "A", Align: JustifyLeft},
&P{Text: "B", Align: JustifyRight},
&P{Text: "C", Align: JustifyCenter},
&P{Text: "D", Align: JustifyFull},
&P{Text: "", Align: JustifyLeft},
&P{Text: "ABCD\nEFGH", Align: JustifyLeft},
}, []base.Widget{
&P{Text: "", Align: JustifyLeft},
&P{Text: "ABCD\nEFGH", Align: JustifyLeft},
&P{Text: "AAA", Align: JustifyRight},
&P{Text: "BAA", Align: JustifyCenter},
&P{Text: "CAA", Align: JustifyFull},
&P{Text: "DAA", Align: JustifyLeft},
})
}