From 624f9a349a781bd287029371b4f5916265bfc728 Mon Sep 17 00:00:00 2001
From: Jez Ng
Date: Tue, 23 Oct 2012 18:46:10 -0400
Subject: Refactor and fix findAndFollowLink. Closes #650.
* Fix bug where symbols that were themselves word boundaries were not
getting matched
* Factor out some operations for efficiency
* Add tests
---
tests/dom_tests/dom_tests.coffee | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
(limited to 'tests/dom_tests')
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 = """
+ nextcorrupted
+ next page
+ """
+ stub settings.values, "nextPatterns", "next"
+ goNext()
+ assert.equal '#second', window.location.hash
+
+ should "match against non-word patterns", ->
+ document.getElementById("test-div").innerHTML = """
+ >>
+ """
+ stub settings.values, "nextPatterns", ">>"
+ goNext()
+ assert.equal '#first', window.location.hash
+
+ should "favor matches with fewer words", ->
+ document.getElementById("test-div").innerHTML = """
+ lorem ipsum next
+ next!
+ """
+ stub settings.values, "nextPatterns", "next"
+ goNext()
+ assert.equal '#second', window.location.hash
+
Tests.outputMethod = (args...) ->
newOutput = args.join "\n"
# escape html
--
cgit v1.2.3