MCPcopy
hub / github.com/yorukot/superfile / updateModelDimensionsAndValidate

Function updateModelDimensionsAndValidate

src/internal/model_layout_test.go:151–236  ·  view source on GitHub ↗

Note: this will create as many panels possible and leave the model in that state This is to ensure that at time of resize operations, there are more panels

(t *testing.T, m *model, width int, height int)

Source from the content-addressed store, hash-verified

149// Note: this will create as many panels possible and leave the model in that state
150// This is to ensure that at time of resize operations, there are more panels
151func updateModelDimensionsAndValidate(t *testing.T, m *model, width int, height int) {
152 // Set Footer OFF, Preview OFF via model state changes
153 // if m.toggleFooter {
154 // TeaUpdate(m, utils.TeaRuneKeyMsg(common.Hotkeys.ToggleFooter[0]))
155 //}
156 // File preview toggle - just send the key, no need to check state
157 // Sending toggle key will turn it off if it's on
158
159 require.True(t, m.toggleFooter)
160 require.True(t, m.fileModel.FilePreview.IsOpen())
161
162 testdata := []struct {
163 name string
164 msg []tea.Msg
165 }{
166 {
167 name: "Resize",
168 msg: []tea.Msg{tea.WindowSizeMsg{Width: width, Height: height}},
169 },
170 {
171 name: "FooterOffPreviewOff",
172 msg: []tea.Msg{
173 utils.TeaRuneKeyMsg(common.Hotkeys.ToggleFooter[0]),
174 utils.TeaRuneKeyMsg(common.Hotkeys.ToggleFilePreviewPanel[0]),
175 },
176 },
177 {
178 name: "ToggleFooterOn",
179 msg: []tea.Msg{utils.TeaRuneKeyMsg(common.Hotkeys.ToggleFooter[0])},
180 },
181 {
182 name: "FooterOffPreviewOn",
183 msg: []tea.Msg{
184 utils.TeaRuneKeyMsg(common.Hotkeys.ToggleFooter[0]),
185 utils.TeaRuneKeyMsg(common.Hotkeys.ToggleFilePreviewPanel[0]),
186 },
187 },
188 {
189 name: "FooterOnAgain",
190 msg: []tea.Msg{utils.TeaRuneKeyMsg(common.Hotkeys.ToggleFooter[0])},
191 },
192 }
193
194 for _, tt := range testdata {
195 t.Run(tt.name, func(t *testing.T) {
196 for _, msg := range tt.msg {
197 TeaUpdate(m, msg)
198 }
199 assertLayoutValidity(t, m)
200 })
201 }
202
203 t.Run("FilePanelRemoval", func(t *testing.T) {
204 for {
205 initialCount := m.fileModel.PanelCount()
206
207 TeaUpdate(m, utils.TeaRuneKeyMsg(common.Hotkeys.CloseFilePanel[0]))
208 assertLayoutValidity(t, m)

Callers 1

testWithConfigFunction · 0.85

Calls 6

TeaRuneKeyMsgFunction · 0.92
TeaUpdateFunction · 0.85
assertLayoutValidityFunction · 0.85
testModelScrollingFunction · 0.85
PanelCountMethod · 0.80
IsOpenMethod · 0.45

Tested by

no test coverage detected