You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
663 B
Go
40 lines
663 B
Go
// +build !convey,!std
|
|
|
|
package incr
|
|
|
|
import (
|
|
"github.com/jordanorelli/tea"
|
|
"testing"
|
|
)
|
|
|
|
type testInt struct {
|
|
X int `tea:"save"`
|
|
}
|
|
|
|
func (testInt) Run(t *testing.T) {}
|
|
|
|
type testIncr struct {
|
|
X int `tea:"load"`
|
|
expect int
|
|
}
|
|
|
|
func (test *testIncr) Run(t *testing.T) {
|
|
test.X++
|
|
if test.X != test.expect {
|
|
t.Errorf("expected X to be %d, is %d instead", test.expect, test.X)
|
|
}
|
|
}
|
|
|
|
func TestOnce(t *testing.T) {
|
|
root := tea.New(&testInt{X: 1})
|
|
root.Child(&testIncr{expect: 2})
|
|
tea.Run(t, root)
|
|
}
|
|
|
|
func TestTwice(t *testing.T) {
|
|
root := tea.New(&testInt{X: 1})
|
|
root.Child(&testIncr{expect: 2})
|
|
root.Child(&testIncr{expect: 2})
|
|
tea.Run(t, root)
|
|
}
|