aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/dom_tests/dom_tests.coffee31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee
index a0254acf..700951c6 100644
--- a/tests/dom_tests/dom_tests.coffee
+++ b/tests/dom_tests/dom_tests.coffee
@@ -183,6 +183,37 @@ context "Input focus",
assert.equal "third", document.activeElement.id
handlerStack.bubbleEvent 'keydown', mockKeyboardEvent("A")
+context "Find prev / next links",
+
+ setup ->
+ window.location.hash = ""
+
+ should "find exact matches", ->
+ document.getElementById("test-div").innerHTML = """
+ <a href='#first'>nextcorrupted</a>
+ <a href='#second'>next page</a>
+ """
+ stub settings.values, "nextPatterns", "next"
+ goNext()
+ assert.equal '#second', window.location.hash
+
+ should "match against non-word patterns", ->
+ document.getElementById("test-div").innerHTML = """
+ <a href='#first'>&gt;&gt;</a>
+ """
+ stub settings.values, "nextPatterns", ">>"
+ goNext()
+ assert.equal '#first', window.location.hash
+
+ should "favor matches with fewer words", ->
+ document.getElementById("test-div").innerHTML = """
+ <a href='#first'>lorem ipsum next</a>
+ <a href='#second'>next!</a>
+ """
+ stub settings.values, "nextPatterns", "next"
+ goNext()
+ assert.equal '#second', window.location.hash
+
Tests.outputMethod = (args...) ->
newOutput = args.join "\n"
# escape html