Skip to content

Commit

Permalink
Extract test helper function checkRemoteBranches
Browse files Browse the repository at this point in the history
We'll need it a few more times in the next test we add.
  • Loading branch information
stefanhaller committed Dec 1, 2024
1 parent 92bce7d commit 0b09105
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 18 deletions.
24 changes: 6 additions & 18 deletions pkg/integration/tests/branch/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,24 +150,12 @@ var Delete = NewIntegrationTest(NewIntegrationTestArgs{
Confirm()
}).
Tap(func() {
t.Views().Remotes().
Focus().
Lines(Contains("origin")).
PressEnter()

t.Views().
RemoteBranches().
Lines(
Equals("branch-five"),
Equals("branch-four"),
Equals("branch-six"),
Equals("branch-two"),
).
Press(keys.Universal.Return)

t.Views().
Branches().
Focus()
checkRemoteBranches(t, keys, "origin", []string{
"branch-five",
"branch-four",
"branch-six",
"branch-two",
})
}).
Lines(
Contains("current-head"),
Expand Down
25 changes: 25 additions & 0 deletions pkg/integration/tests/branch/shared.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package branch

import (
"github.com/jesseduffield/lazygit/pkg/config"
. "github.com/jesseduffield/lazygit/pkg/integration/components"
"github.com/samber/lo"
)

func checkRemoteBranches(t *TestDriver, keys config.KeybindingConfig, remoteName string, expectedBranches []string) {
t.Views().Remotes().
Focus().
NavigateToLine(Contains(remoteName)).
PressEnter()

t.Views().
RemoteBranches().
Lines(
lo.Map(expectedBranches, func(branch string, _ int) *TextMatcher { return Equals(branch) })...,
).
Press(keys.Universal.Return)

t.Views().
Branches().
Focus()
}

0 comments on commit 0b09105

Please sign in to comment.