1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-20 05:19:24 +02:00
lazygit/pkg/integration/components/menu_asserter.go
2022-12-27 21:26:18 +11:00

45 lines
985 B
Go

package components
type MenuAsserter struct {
assert *Assert
input *Input
hasCheckedTitle bool
}
func (self *MenuAsserter) getViewAsserter() *ViewAsserter {
return self.assert.View("menu")
}
// asserts that the popup has the expected title
func (self *MenuAsserter) Title(expected *matcher) *MenuAsserter {
self.getViewAsserter().Title(expected)
self.hasCheckedTitle = true
return self
}
func (self *MenuAsserter) Confirm() {
self.checkNecessaryChecksCompleted()
self.input.Confirm()
}
func (self *MenuAsserter) Cancel() {
self.checkNecessaryChecksCompleted()
self.input.Press(self.input.keys.Universal.Return)
}
func (self *MenuAsserter) Select(option *matcher) *MenuAsserter {
self.input.NavigateToListItem(option)
return self
}
func (self *MenuAsserter) checkNecessaryChecksCompleted() {
if !self.hasCheckedTitle {
self.assert.Fail("You must check the title of a menu popup by calling Title() before calling Confirm()/Cancel().")
}
}