forked from fynelabs/notes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_test.go
55 lines (41 loc) · 1010 Bytes
/
main_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
package main
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"fyne.io/fyne/v2/data/binding"
"fyne.io/fyne/v2/test"
)
func testGUI() *ui {
str1 := "1"
str2 := "2"
l := ¬elist{pref: test.NewApp().Preferences(),
all: []*note{
{content: binding.BindString(&str1), deleted: binding.NewBool()},
{content: binding.BindString(&str2), deleted: binding.NewBool()},
}}
gui := &ui{notes: l}
_ = gui.loadUI()
return gui
}
func TestUIList(t *testing.T) {
gui := testGUI()
assert.Equal(t, 2, gui.list.Length())
}
func TestUIList_TapSetsContent(t *testing.T) {
gui := testGUI()
assert.Equal(t, "1", gui.content.Text)
gui.list.Select(1) // this happens on a goroutine
time.Sleep(time.Millisecond * 100)
assert.Equal(t, "2", gui.content.Text)
}
func TestUIAdd(t *testing.T) {
gui := testGUI()
gui.addNote()
assert.Equal(t, 3, gui.list.Length())
}
func TestUIRemove(t *testing.T) {
gui := testGUI()
gui.removeCurrentNote()
assert.Equal(t, 1, gui.list.Length())
}