MCPcopy Create free account
hub / github.com/cogentcore/core / TestKeyedListChangeKey

Function TestKeyedListChangeKey

core/keyedlist_test.go:59–77  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func 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}

Callers

nothing calls this directly

Calls 10

AssertRenderMethod · 0.95
NewBodyFunction · 0.85
NewKeyedListFunction · 0.85
SendChangeMethod · 0.80
ChildMethod · 0.80
EqualMethod · 0.80
CopyMethod · 0.65
SetMapMethod · 0.45
OnChangeMethod · 0.45
SetTextMethod · 0.45

Tested by

no test coverage detected