| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package wbutton
- import (
- "testing"
- . "gitp78su.ipnodns.ru/svi/kern/v4/lev0/ktypes"
- . "gitp78su.ipnodns.ru/svi/kern/v4/lev1/result"
- )
- type tester struct {
- t *testing.T
- chCall chan string
- }
- func TestWuiButton(t *testing.T) {
- sf := &tester{
- t: t,
- chCall: make(chan string, 2),
- }
- sf.new()
- }
- // Создание кнопки.
- func (sf *tester) new() {
- sf.t.Log("new")
- btn := NewWuiButton("test_val", sf.fnBack).Hassert("new()")
- if btn == nil {
- sf.t.Fatalf("new(): WuiButton==nil")
- }
- if txt := btn.Text(); txt == nil {
- sf.t.Fatalf("new(): IWuiText==nil")
- }
- if html := btn.Html(); html == "" {
- sf.t.Fatalf("new(): html is empty")
- }
- if hx := btn.Hx(); hx == nil {
- sf.t.Fatalf("new(): IWuiHx==nil")
- }
- btn.Click(map[string]string{}).Hassert("new()")
- if str := <-sf.chCall; str != "test" {
- sf.t.Fatalf("new(): bad called")
- }
- }
- // Функция обратного вызова.
- func (sf *tester) fnBack(dict map[string]string) IResult[string] {
- sf.chCall <- "test"
- return NewRes("test_click")
- }
|