aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPhil Crosby2012-06-03 16:45:09 -0700
committerPhil Crosby2012-06-03 16:56:39 -0700
commit79fc51ab7ba61ef836f5a208dbf3a4c1dcdb4c53 (patch)
tree2d2d0e03cae1e711f1aa2cb808f945a69fb7d6f2 /tests
parent98e9e8ca04918de3fae369e1f3b0285ba17d4188 (diff)
downloadvimium-79fc51ab7ba61ef836f5a208dbf3a4c1dcdb4c53.tar.bz2
Fix a highlighting bug where we overlapping query terms would corrupt the html
Diffstat (limited to 'tests')
-rw-r--r--tests/completion_test.coffee10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/completion_test.coffee b/tests/completion_test.coffee
index dadf5860..edb1b59f 100644
--- a/tests/completion_test.coffee
+++ b/tests/completion_test.coffee
@@ -73,8 +73,14 @@ context "suggestions",
assert.isTrue suggestion.generateHtml().indexOf("title <span>") >= 0
should "highlight query words", ->
- suggestion = new Suggestion(["ninja"], "tab", "url", "ninjawords", returns(1))
- assert.isTrue suggestion.generateHtml().indexOf("<span class='match'>ninja</span>words") >= 0
+ suggestion = new Suggestion(["ninj", "words"], "tab", "url", "ninjawords", returns(1))
+ expected = "<span class='match'>ninj</span>a<span class='match'>words</span>"
+ assert.isTrue suggestion.generateHtml().indexOf(expected) >= 0
+
+ should "highlight query words correctly when whey they overlap", ->
+ suggestion = new Suggestion(["ninj", "jaword"], "tab", "url", "ninjawords", returns(1))
+ expected = "<span class='match'>ninjaword</span>s"
+ assert.isTrue suggestion.generateHtml().indexOf(expected) >= 0
should "shorten urls", ->
suggestion = new Suggestion(["queryterm"], "tab", "http://ninjawords.com", "ninjawords", returns(1))