(t *testing.T)
| 57 | } |
| 58 | |
| 59 | func TestKeyedListChangeKey(t *testing.T) { |
| 60 | b := NewBody() |
| 61 | m := map[string]int{"Go": 1, "C++": 3, "Python": 5} |
| 62 | |
| 63 | n := 0 |
| 64 | value := map[string]int{} |
| 65 | mv := NewKeyedList(b).SetMap(&m) |
| 66 | mv.OnChange(func(e events.Event) { |
| 67 | n++ |
| 68 | maps.Copy(value, m) |
| 69 | }) |
| 70 | b.AssertRender(t, "keyed-list/change-key", func() { |
| 71 | // [4] is key of third row, which is "Python" since it is sorted alphabetically |
| 72 | mv.Child(4).(*TextField).SetText("JavaScript").SendChange() |
| 73 | assert.Equal(t, 1, n) |
| 74 | assert.Equal(t, m, value) |
| 75 | assert.Equal(t, map[string]int{"Go": 1, "C++": 3, "JavaScript": 5}, m) |
| 76 | }) |
| 77 | } |
nothing calls this directly
no test coverage detected