1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-14 11:23:09 +02:00
lazygit/pkg/integration/components/confirmation_driver.go
2022-12-28 11:27:48 +11:00

48 lines
1.2 KiB
Go

package components
type ConfirmationDriver struct {
t *TestDriver
hasCheckedTitle bool
hasCheckedContent bool
}
func (self *ConfirmationDriver) getViewDriver() *ViewDriver {
return self.t.Views().Confirmation()
}
// asserts that the confirmation view has the expected title
func (self *ConfirmationDriver) Title(expected *matcher) *ConfirmationDriver {
self.getViewDriver().Title(expected)
self.hasCheckedTitle = true
return self
}
// asserts that the confirmation view has the expected content
func (self *ConfirmationDriver) Content(expected *matcher) *ConfirmationDriver {
self.getViewDriver().Content(expected)
self.hasCheckedContent = true
return self
}
func (self *ConfirmationDriver) Confirm() {
self.checkNecessaryChecksCompleted()
self.getViewDriver().PressEnter()
}
func (self *ConfirmationDriver) Cancel() {
self.checkNecessaryChecksCompleted()
self.getViewDriver().PressEscape()
}
func (self *ConfirmationDriver) checkNecessaryChecksCompleted() {
if !self.hasCheckedContent || !self.hasCheckedTitle {
self.t.Fail("You must both check the content and title of a confirmation popup by calling Title()/Content() before calling Confirm()/Cancel().")
}
}