Fixes tests for Vim mode
Vim mode still needs a lot more tests
This commit is contained in:
parent
e3568cd949
commit
3beeb76668
|
@ -11,6 +11,9 @@ import (
|
|||
"github.com/gdamore/tcell"
|
||||
)
|
||||
|
||||
// TODO: A little description as to the respective responsibilties of this code versus the
|
||||
// vimium.js code.
|
||||
|
||||
// TODO: Capitalised variables mean that developers can expect them to be publically availably
|
||||
// as part of the API of the package. I don't think that is the intended case here.
|
||||
type VimMode int
|
||||
|
@ -71,6 +74,7 @@ var (
|
|||
linkHintWriteStringCalls *func()
|
||||
)
|
||||
|
||||
// TODO: What's this for?
|
||||
func init() {
|
||||
setupLinkHints()
|
||||
}
|
||||
|
|
|
@ -130,6 +130,9 @@ func GotoURL(url string) {
|
|||
Keyboard(url)
|
||||
SpecialKey(tcell.KeyEnter)
|
||||
WaitForPageLoad()
|
||||
// Hack to force text to be rerendered. Because there's a bug where text sometimes doesn't get
|
||||
// rendered.
|
||||
mouseClick(3, 3)
|
||||
// TODO: Looking for the URL isn't optimal because it could be the same URL
|
||||
// as the previous test.
|
||||
gomega.Expect(url).To(BeInFrameAt(0, 1))
|
||||
|
@ -189,7 +192,7 @@ func GetBgColour(x, y int) [3]int32 {
|
|||
}
|
||||
|
||||
func ensureOnlyOneTab() {
|
||||
if len(browsh.Tabs) > 1 {
|
||||
for len(browsh.Tabs) > 1 {
|
||||
SpecialKey(tcell.KeyCtrlW)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"browsh/interfacer/src/browsh"
|
||||
"testing"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
|
@ -13,7 +14,7 @@ func TestMain(t *testing.T) {
|
|||
RunSpecs(t, "Integration tests")
|
||||
}
|
||||
|
||||
var _ = Describe("Showing a basic webpage", func() {
|
||||
var _ = Describe("Core functionality", func() {
|
||||
BeforeEach(func() {
|
||||
GotoURL(testSiteURL + "/smorgasbord/")
|
||||
})
|
||||
|
@ -106,10 +107,10 @@ var _ = Describe("Showing a basic webpage", func() {
|
|||
|
||||
It("should enter multiple lines of text", func() {
|
||||
Keyboard(`So here is a lot of text that will hopefully split across lines`)
|
||||
Expect("So here is a lot of").To(BeInFrameAt(1, 3))
|
||||
Expect("text that will").To(BeInFrameAt(1, 4))
|
||||
Expect("hopefully split across").To(BeInFrameAt(1, 5))
|
||||
Expect("lines").To(BeInFrameAt(1, 6))
|
||||
Expect("So here is a lot of").To(BeInFrameAt(1, 2))
|
||||
Expect("text that will").To(BeInFrameAt(1, 3))
|
||||
Expect("hopefully split across").To(BeInFrameAt(1, 4))
|
||||
Expect("lines").To(BeInFrameAt(1, 5))
|
||||
})
|
||||
|
||||
It("should scroll multiple lines of text", func() {
|
||||
|
@ -120,37 +121,33 @@ var _ = Describe("Showing a basic webpage", func() {
|
|||
for i := 1; i <= 6; i++ {
|
||||
SpecialKey(tcell.KeyUp)
|
||||
}
|
||||
Expect("lines").To(BeInFrameAt(1, 6))
|
||||
Expect("lines").To(BeInFrameAt(1, 5))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Describe("Tabs", func() {
|
||||
BeforeEach(func() {
|
||||
SpecialKey(tcell.KeyCtrlT)
|
||||
})
|
||||
|
||||
AfterEach(func() {
|
||||
ensureOnlyOneTab()
|
||||
})
|
||||
|
||||
It("should create a new tab", func() {
|
||||
Expect("New Tab").To(BeInFrameAt(21, 0))
|
||||
SpecialKey(tcell.KeyCtrlT)
|
||||
Expect(len(browsh.Tabs)).To(Equal(2))
|
||||
})
|
||||
|
||||
It("should be able to goto a new URL", func() {
|
||||
Keyboard(testSiteURL + "/smorgasbord/another.html")
|
||||
SpecialKey(tcell.KeyEnter)
|
||||
Expect("Another").To(BeInFrameAt(21, 0))
|
||||
SpecialKey(tcell.KeyCtrlT)
|
||||
GotoURL(testSiteURL + "/smorgasbord/another.html")
|
||||
Expect("Another▄webpage").To(BeInFrameAt(1, 3))
|
||||
})
|
||||
|
||||
It("should cycle to the next tab", func() {
|
||||
Expect(" ").To(BeInFrameAt(0, 1))
|
||||
SpecialKey(tcell.KeyCtrlL)
|
||||
GotoURL(testSiteURL + "/smorgasbord/")
|
||||
SpecialKey(tcell.KeyCtrlT)
|
||||
GotoURL(testSiteURL + "/smorgasbord/another.html")
|
||||
triggerUserKeyFor("tty.keys.next-tab")
|
||||
URL := testSiteURL + "/smorgasbord/ "
|
||||
Expect(URL).To(BeInFrameAt(0, 1))
|
||||
Expect("Smörgåsbord").To(BeInFrameAt(0, 0))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
@ -41,9 +41,10 @@ var _ = Describe("Vim tests", func() {
|
|||
})
|
||||
|
||||
It("should cycle to the next tab", func() {
|
||||
GotoURL(testSiteURL + "/smorgasbord/")
|
||||
Keyboard("t")
|
||||
GotoURL(testSiteURL + "/smorgasbord/another.html")
|
||||
Keyboard("gt")
|
||||
Keyboard("J")
|
||||
URL := testSiteURL + "/smorgasbord/ "
|
||||
Expect(URL).To(BeInFrameAt(0, 1))
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue