-
Notifications
You must be signed in to change notification settings - Fork 1
/
textarea_test.go
54 lines (46 loc) · 1.33 KB
/
textarea_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
package goey
import (
"bytes"
"testing"
"bitbucket.org/rj/goey/base"
)
func TestTextAreaMount(t *testing.T) {
// Note, cannot use zero value for MinLines. This will be changed to a
// default value, and cause the post mounting check that the widget was
// correctly instantiated to fail.
testingMountWidgets(t,
&TextArea{Value: "A", MinLines: 3},
&TextArea{Value: "B", MinLines: 3, Placeholder: "..."},
&TextArea{Value: "C", MinLines: 3, Disabled: true},
)
}
func TestTextAreaOnFocus(t *testing.T) {
testingCheckFocusAndBlur(t,
&TextArea{},
&TextArea{},
&TextArea{},
)
}
func TestTextAreaOnChange(t *testing.T) {
log := bytes.NewBuffer(nil)
testingTypeKeys(t, "Hello",
&TextArea{OnChange: func(v string) {
log.WriteString(v)
log.WriteString("\x1E")
}})
const want = "H\x1EHe\x1EHel\x1EHell\x1EHello\x1E"
if got := log.String(); got != want {
t.Errorf("Wanted %v, got %v", want, got)
}
}
func TestTextAreaUpdateProps(t *testing.T) {
testingUpdateWidgets(t, []base.Widget{
&TextArea{Value: "A", MinLines: 5},
&TextArea{Value: "B", MinLines: 3, Placeholder: "..."},
&TextArea{Value: "C", MinLines: 3, Disabled: true},
}, []base.Widget{
&TextArea{Value: "AA", MinLines: 6},
&TextArea{Value: "BA", MinLines: 3, Disabled: true},
&TextArea{Value: "CA", MinLines: 3, Placeholder: "***", Disabled: false},
})
}