diff options
| author | Jez Ng | 2012-10-23 18:46:10 -0400 | 
|---|---|---|
| committer | Jez Ng | 2012-10-23 18:46:10 -0400 | 
| commit | 624f9a349a781bd287029371b4f5916265bfc728 (patch) | |
| tree | 10075f2e283f8008ffbb046fcdfec4a9fa076725 /tests | |
| parent | c128ee99fd8fc5cf5044099f6cb20847fee99b24 (diff) | |
| download | vimium-624f9a349a781bd287029371b4f5916265bfc728.tar.bz2 | |
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
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/dom_tests/dom_tests.coffee | 31 | 
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'>>></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 | 
