From 79fc51ab7ba61ef836f5a208dbf3a4c1dcdb4c53 Mon Sep 17 00:00:00 2001
From: Phil Crosby
Date: Sun, 3 Jun 2012 16:45:09 -0700
Subject: Fix a highlighting bug where we overlapping query terms would corrupt
the html
---
tests/completion_test.coffee | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
(limited to 'tests')
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("ninjawords") >= 0
+ suggestion = new Suggestion(["ninj", "words"], "tab", "url", "ninjawords", returns(1))
+ expected = "ninjawords"
+ 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 = "ninjawords"
+ assert.isTrue suggestion.generateHtml().indexOf(expected) >= 0
should "shorten urls", ->
suggestion = new Suggestion(["queryterm"], "tab", "http://ninjawords.com", "ninjawords", returns(1))
--
cgit v1.2.3