wui_button_test.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package wui_button
  2. import (
  3. "testing"
  4. mKt "gitp78su.ipnodns.ru/svi/kern/v4/lev0/ktypes"
  5. mL1 "gitp78su.ipnodns.ru/svi/kern/v4/lev1"
  6. )
  7. type tester struct {
  8. t *testing.T
  9. chCall chan string
  10. }
  11. func TestWuiButton(t *testing.T) {
  12. sf := &tester{
  13. t: t,
  14. chCall: make(chan string, 2),
  15. }
  16. sf.new()
  17. }
  18. // Создание кнопки.
  19. func (sf *tester) new() {
  20. sf.t.Log("new")
  21. btn := NewWuiButton("test_val", sf.fnBack).Hassert("new()")
  22. if btn == nil {
  23. sf.t.Fatalf("new(): WuiButton==nil")
  24. }
  25. if txt := btn.Text(); txt == nil {
  26. sf.t.Fatalf("new(): IWuiText==nil")
  27. }
  28. if html := btn.Html(); html == "" {
  29. sf.t.Fatalf("new(): html is empty")
  30. }
  31. if hx := btn.Hx(); hx == nil {
  32. sf.t.Fatalf("new(): IWuiHx==nil")
  33. }
  34. btn.Click(map[string]string{}).Hassert("new()")
  35. if str := <-sf.chCall; str != "test" {
  36. sf.t.Fatalf("new(): bad called")
  37. }
  38. }
  39. // Функция обратного вызова.
  40. func (sf *tester) fnBack(dict map[string]string) mKt.IResult[string] {
  41. sf.chCall <- "test"
  42. return mL1.NewRes("test_click")
  43. }