1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

cleaner test assertions

This commit is contained in:
Jesse Duffield
2022-12-26 11:12:56 +11:00
parent fa0414777f
commit 9a6f21ce42
34 changed files with 442 additions and 378 deletions

View File

@ -31,7 +31,7 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
assert.CommitCount(3)
input.SwitchToCommitsWindow()
assert.CurrentViewName("commits")
assert.CurrentView().Name("commits")
mergeCommitMessage := "Merge branch 'feature-branch' into development-branch"
assert.HeadCommitMessage(Contains(mergeCommitMessage))
@ -44,7 +44,8 @@ var AmendMerge = NewIntegrationTest(NewIntegrationTestArgs{
assert.HeadCommitMessage(Contains(mergeCommitMessage))
// assuring the post-merge file shows up in the merge commit.
assert.MainViewContent(Contains(postMergeFilename))
assert.MainViewContent(Contains("++" + postMergeFileContent))
assert.MainView().
Content(Contains(postMergeFilename)).
Content(Contains("++" + postMergeFileContent))
},
})

View File

@ -16,26 +16,61 @@ var One = NewIntegrationTest(NewIntegrationTestArgs{
},
Run: func(shell *Shell, input *Input, assert *Assert, keys config.KeybindingConfig) {
input.SwitchToCommitsWindow()
assert.CurrentViewName("commits")
assert.CurrentView().Name("commits").Lines(
Contains("commit 05"),
Contains("commit 04"),
Contains("commit 03"),
Contains("commit 02"),
Contains("commit 01"),
)
input.NavigateToListItem(Contains("commit 02"))
input.Press(keys.Universal.Edit)
assert.CurrentLine(Contains("YOU ARE HERE"))
assert.CurrentView().Lines(
MatchesRegexp("pick.*commit 05"),
MatchesRegexp("pick.*commit 04"),
MatchesRegexp("pick.*commit 03"),
MatchesRegexp("YOU ARE HERE.*commit 02"),
Contains("commit 01"),
)
input.PreviousItem()
input.Press(keys.Commits.MarkCommitAsFixup)
assert.CurrentLine(Contains("fixup"))
assert.CurrentView().Lines(
MatchesRegexp("pick.*commit 05"),
MatchesRegexp("pick.*commit 04"),
MatchesRegexp("fixup.*commit 03"),
MatchesRegexp("YOU ARE HERE.*commit 02"),
Contains("commit 01"),
)
input.PreviousItem()
input.Press(keys.Universal.Remove)
assert.CurrentLine(Contains("drop"))
assert.CurrentView().Lines(
MatchesRegexp("pick.*commit 05"),
MatchesRegexp("drop.*commit 04"),
MatchesRegexp("fixup.*commit 03"),
MatchesRegexp("YOU ARE HERE.*commit 02"),
Contains("commit 01"),
)
input.PreviousItem()
input.Press(keys.Commits.SquashDown)
assert.CurrentLine(Contains("squash"))
assert.CurrentView().Lines(
MatchesRegexp("squash.*commit 05"),
MatchesRegexp("drop.*commit 04"),
MatchesRegexp("fixup.*commit 03"),
MatchesRegexp("YOU ARE HERE.*commit 02"),
Contains("commit 01"),
)
input.ContinueRebase()
assert.CommitCount(2)
assert.CurrentView().Lines(
Contains("commit 02"),
Contains("commit 01"),
)
},
})