mirror of
https://github.com/jesseduffield/lazygit.git
synced 2024-12-04 10:34:55 +02:00
54 lines
1.3 KiB
Go
54 lines
1.3 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 *TextMatcher) *ConfirmationDriver {
|
|
self.getViewDriver().Title(expected)
|
|
|
|
self.hasCheckedTitle = true
|
|
|
|
return self
|
|
}
|
|
|
|
// asserts that the confirmation view has the expected content
|
|
func (self *ConfirmationDriver) Content(expected *TextMatcher) *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) Wait(milliseconds int) *ConfirmationDriver {
|
|
self.getViewDriver().Wait(milliseconds)
|
|
|
|
return self
|
|
}
|
|
|
|
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().")
|
|
}
|
|
}
|