Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cfoust committed Nov 11, 2023
1 parent bbdb6c1 commit 3ba2582
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/mux/screen/replay/replay_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,17 @@ func createTest(events []sessions.Event) (*Replay, func(msgs ...interface{})) {
m, cmd = m.Update(realMsg)
m.View(tty.New(geom.DEFAULT_SIZE))
for cmd != nil {
m, cmd = m.Update(cmd())
msg := cmd()

switch msg := msg.(type) {
case tea.BatchMsg:
for _, cmd := range msg {
m, _ = m.Update(cmd())
}
cmd = nil
default:
m, cmd = m.Update(msg)
}
m.View(tty.New(geom.DEFAULT_SIZE))
}
}
Expand All @@ -83,6 +93,7 @@ func TestSearch(t *testing.T) {
)

r, i := createTest(s.Events())
r.searchProgress = nil
i(ActionBeginning, ActionSearchForward, "bar", "enter")
require.Equal(t, 3, len(r.matches))
require.Equal(t, 2, r.location.Index)
Expand Down
4 changes: 4 additions & 0 deletions pkg/mux/screen/replay/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ type progressEvent struct {
}

func (r *Replay) waitProgress() tea.Cmd {
if r.searchProgress == nil {
return nil
}

return func() tea.Msg {
return progressEvent{
value: <-r.searchProgress,
Expand Down
1 change: 1 addition & 0 deletions pkg/sessions/search/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestBasic(t *testing.T) {
"baz",
),
"^bar",
nil,
)
require.Equal(t, 1, len(results))
require.Equal(t, SearchResult{
Expand Down

0 comments on commit 3ba2582

Please sign in to comment.