mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-30 03:23:08 +03:00
rename from asserter to driver
This commit is contained in:
47
pkg/integration/components/alert_driver.go
Normal file
47
pkg/integration/components/alert_driver.go
Normal file
@ -0,0 +1,47 @@
|
||||
package components
|
||||
|
||||
type AlertDriver struct {
|
||||
t *TestDriver
|
||||
hasCheckedTitle bool
|
||||
hasCheckedContent bool
|
||||
}
|
||||
|
||||
func (self *AlertDriver) getViewDriver() *ViewDriver {
|
||||
return self.t.Views().Confirmation()
|
||||
}
|
||||
|
||||
// asserts that the alert view has the expected title
|
||||
func (self *AlertDriver) Title(expected *matcher) *AlertDriver {
|
||||
self.getViewDriver().Title(expected)
|
||||
|
||||
self.hasCheckedTitle = true
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
// asserts that the alert view has the expected content
|
||||
func (self *AlertDriver) Content(expected *matcher) *AlertDriver {
|
||||
self.getViewDriver().Content(expected)
|
||||
|
||||
self.hasCheckedContent = true
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
func (self *AlertDriver) Confirm() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.getViewDriver().PressEnter()
|
||||
}
|
||||
|
||||
func (self *AlertDriver) Cancel() {
|
||||
self.checkNecessaryChecksCompleted()
|
||||
|
||||
self.getViewDriver().PressEscape()
|
||||
}
|
||||
|
||||
func (self *AlertDriver) 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().")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user