diff options
author | Thomas Buckley-Houston <tom@tombh.co.uk> | 2018-11-11 23:15:35 +0900 |
---|---|---|
committer | Thomas Buckley-Houston <tom@tombh.co.uk> | 2019-06-24 09:12:11 +0300 |
commit | 59d2c31acf8f96b6b18555cd86eefc2bb7bab37b (patch) | |
tree | ce9c3d2b9c394204f4b038d36784d40335a9f6ca | |
parent | eae72e94a635958876e4c115978fc6b39caf2609 (diff) |
Fixes tests for Vim mode
Vim mode still needs a lot more tests
-rw-r--r-- | interfacer/src/browsh/vim_mode.go | 4 | ||||
-rw-r--r-- | interfacer/test/tty/setup.go | 5 | ||||
-rw-r--r-- | interfacer/test/tty/tty_test.go | 33 | ||||
-rw-r--r-- | interfacer/test/tty/vim_test.go | 3 |
4 files changed, 25 insertions, 20 deletions
diff --git a/interfacer/src/browsh/vim_mode.go b/interfacer/src/browsh/vim_mode.go index cd3ad67..0ec0482 100644 --- a/interfacer/src/browsh/vim_mode.go +++ b/interfacer/src/browsh/vim_mode.go @@ -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() } diff --git a/interfacer/test/tty/setup.go b/interfacer/test/tty/setup.go index 876c4f1..2b7dbbb 100644 --- a/interfacer/test/tty/setup.go +++ b/interfacer/test/tty/setup.go @@ -149,6 +149,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)) @@ -214,7 +217,7 @@ func GetBgColour(x, y int) [3]int32 { } func ensureOnlyOneTab() { - if len(browsh.Tabs) > 1 { + for len(browsh.Tabs) > 1 { SpecialKey(tcell.KeyCtrlW) } } diff --git a/interfacer/test/tty/tty_test.go b/interfacer/test/tty/tty_test.go index 417b860..b138047 100644 --- a/interfacer/test/tty/tty_test.go +++ b/interfacer/test/tty/tty_test.go @@ -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)) }) }) }) diff --git a/interfacer/test/tty/vim_test.go b/interfacer/test/tty/vim_test.go index 3487a02..b52f7d7 100644 --- a/interfacer/test/tty/vim_test.go +++ b/interfacer/test/tty/vim_test.go @@ -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)) }) |