MCPcopy Create free account
hub / github.com/basecamp/hey-cli / TestMailViewSubnavLeftRight

Function TestMailViewSubnavLeftRight

internal/tui/mail_test.go:197–227  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

195 _, consumed := v.Update(currentPostingsLoaded(v, testPostings()))
196 if !consumed {
197 t.Error("postingsLoadedMsg should be consumed")
198 }
199 if v.requests.loading {
200 t.Error("loading should be false after postings loaded")
201 }
202 if len(v.postingList.postings) != 2 {
203 t.Errorf("expected 2 postings, got %d", len(v.postingList.postings))
204 }
205}
206
207func TestMailViewIgnoresPostingLoadFromEarlierBoxVisit(t *testing.T) {
208 v := mailWithPostings()
209
210 v.SubnavRight()
211 stale := currentPostingsLoaded(v, []mail.Posting{{ID: 200, Summary: "The Feed message"}})
212 v.SubnavLeft()
213 current := currentPostingsLoaded(v, []mail.Posting{{ID: 300, Summary: "Current Imbox message"}})
214 v.Update(current)
215 v.Update(stale)
216
217 if len(v.postingList.postings) != 1 || v.postingList.postings[0].ID != 300 {
218 t.Errorf("an earlier box visit overwrote the current postings: %v", v.postingList.postings)
219 }
220}
221
222func TestMailViewReportsCurrentPostingLoadFailure(t *testing.T) {
223 v, _ := mailWithTestServer(t, http.StatusBadRequest)
224
225 failed, ok := runCmd(v.SubnavRight()).(postingsLoadedMsg)
226 if !ok || failed.err == nil {
227 t.Fatalf("posting load returned %#v, want an error", failed)
228 }
229 cmd, consumed := v.Update(failed)
230

Callers

nothing calls this directly

Calls 4

mailWithPostingsFunction · 0.85
SubnavLeftMethod · 0.65
SubnavRightMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected