aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2014-11-08 07:07:06 +0000
committerStephen Blott2014-11-08 07:07:06 +0000
commit1e9687d667febe575db1c66aeaaca7e8954bc31f (patch)
treedeaeb8884daa2c2da1cea31448592470a5316954
parenta61de15c2f21e2a27f09b088dea09c1cefe699d1 (diff)
downloadvimium-1e9687d667febe575db1c66aeaaca7e8954bc31f.tar.bz2
Tabs order; more tests.
-rw-r--r--tests/unit_tests/completion_test.coffee22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/unit_tests/completion_test.coffee b/tests/unit_tests/completion_test.coffee
index ee758dbb..dc4f3848 100644
--- a/tests/unit_tests/completion_test.coffee
+++ b/tests/unit_tests/completion_test.coffee
@@ -404,9 +404,20 @@ context "TabRecency",
@tabRecency = new TabRecency()
@tabRecency.add 3
@tabRecency.add 2
+ @tabRecency.add 9
@tabRecency.add 1
+ @tabRecency.remove 9
@tabRecency.add 4
+ should "have entries for active tabs", ->
+ assert.isTrue @tabRecency.cache[1]
+ assert.isTrue @tabRecency.cache[2]
+ assert.isTrue @tabRecency.cache[3]
+ assert.isTrue @tabRecency.cache[4]
+
+ should "not have entries for removed tabs", ->
+ assert.isFalse @tabRecency.cache[9]
+
should "give a high score to the most recent tab", ->
assert.isTrue @tabRecency.recencyScore(4) < @tabRecency.recencyScore 1
assert.isTrue @tabRecency.recencyScore(3) < @tabRecency.recencyScore 1
@@ -417,6 +428,17 @@ context "TabRecency",
assert.isTrue @tabRecency.recencyScore(2) > @tabRecency.recencyScore 4
assert.isTrue @tabRecency.recencyScore(3) > @tabRecency.recencyScore 4
+ should "rank tabs by recency", ->
+ assert.isTrue @tabRecency.recencyScore(3) < @tabRecency.recencyScore 2
+ assert.isTrue @tabRecency.recencyScore(2) < @tabRecency.recencyScore 1
+ @tabRecency.add 3
+ @tabRecency.add 4 # Making 3 the most recent tab which isn't the current tab.
+ assert.isTrue @tabRecency.recencyScore(1) < @tabRecency.recencyScore 3
+ assert.isTrue @tabRecency.recencyScore(2) < @tabRecency.recencyScore 3
+ assert.isTrue @tabRecency.recencyScore(4) < @tabRecency.recencyScore 3
+ assert.isTrue @tabRecency.recencyScore(4) < @tabRecency.recencyScore 1
+ assert.isTrue @tabRecency.recencyScore(4) < @tabRecency.recencyScore 2
+
# A convenience wrapper around completer.filter() so it can be called synchronously in tests.
filterCompleter = (completer, queryTerms) ->
results = []