Skip to content

Commit 2b1e7b1

Browse files
Extend unit tests for RankingUtils.
1. Add additional tests for `RankingUtils.matches()`. 2. Add tests for `RankingUtils.wordRelevancy()`.
1 parent 61adf18 commit 2b1e7b1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

tests/unit_tests/completion_test.coffee

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,19 @@ context "suggestions",
153153

154154
context "RankingUtils",
155155
should "do a case insensitive match", ->
156-
assert.isTrue RankingUtils.matches(["maRiO"], "MARIO", "MARIo")
156+
assert.isTrue RankingUtils.matches(["aRi"], "MARIO", "MARio")
157157

158+
should "do a case insensitive match on full term", ->
159+
assert.isTrue RankingUtils.matches(["MaRiO"], "MARIO", "MARio")
160+
161+
should "do a case insensitive match on more than just two terms", ->
162+
assert.isTrue RankingUtils.matches(["aRi"], "DOES_NOT_MATCH", "DOES_NOT_MATCH_EITHER", "MARio")
163+
164+
should "do case insensitive word relevancy (matching)", ->
165+
assert.isTrue RankingUtils.wordRelevancy(["aRi"], "MARIO", "MARio") > 0.0
166+
167+
should "do case insensitive word relevancy (not matching)", ->
168+
assert.isTrue RankingUtils.wordRelevancy(["DOES_NOT_MATCH"], "MARIO", "MARio") == 0.0
158169

159170
# A convenience wrapper around completer.filter() so it can be called synchronously in tests.
160171
filterCompleter = (completer, queryTerms) ->

0 commit comments

Comments
 (0)