From 65c6dd4ccf94660697acfd073ea6e4b714c4eb4f Mon Sep 17 00:00:00 2001 From: Phil Crosby Date: Sun, 10 Jun 2012 00:27:11 -0700 Subject: Ensure matches are case insensitive, and cache regexp's so they're not created excessively. --- tests/completion_test.coffee | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/completion_test.coffee b/tests/completion_test.coffee index ed864151..218225d4 100644 --- a/tests/completion_test.coffee +++ b/tests/completion_test.coffee @@ -19,8 +19,8 @@ context "bookmark completer", should "return matching bookmarks when searching", -> @completer.refresh() - @completer.filter(["mark2"], (@results) =>) - assert.arrayEqual [@bookmark2.url], @results.map (suggestion) -> suggestion.url + results = filterCompleter(@completer, ["mark2"]) + assert.arrayEqual [@bookmark2.url], results.map (suggestion) -> suggestion.url context "HistoryCache", context "binary search", @@ -138,6 +138,11 @@ context "suggestions", suggestion = new Suggestion(["queryterm"], "tab", "http://ninjawords.com", "ninjawords", returns(1)) assert.equal -1, suggestion.generateHtml().indexOf("http://ninjawords.com") +context "RankingUtils", + should "do a case insensitive match", -> + assert.isTrue RankingUtils.matches(["maRiO"], "MARIO", "MARIo") + + # A convenience wrapper around completer.filter() so it can be called synchronously in tests. filterCompleter = (completer, queryTerms) -> results = [] -- cgit v1.2.3