| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package wui_button
- import (
- "testing"
- mL0 "gitp78su.ipnodns.ru/svi/kern/v4/lev0"
- "gitp78su.ipnodns.ru/svi/kern/v4/lev0/defs"
- )
- 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(defs.Txt("test_val"), sf.fnBack)
- 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.Get() == "" {
- 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(defs.Txt("new()"))
- if str := <-sf.chCall; str != "test" {
- sf.t.Fatalf("new(): bad called")
- }
- }
- // Функция обратного вызова.
- func (sf *tester) fnBack(dict map[string]string) mL0.IResult[defs.ITxtFix] {
- sf.chCall <- "test"
- return mL0.NewOk(defs.TxtFix("test_click"))
- }
|