diff options
| author | Stephen Blott | 2014-11-08 06:51:44 +0000 |
|---|---|---|
| committer | Stephen Blott | 2014-11-08 06:51:44 +0000 |
| commit | a61de15c2f21e2a27f09b088dea09c1cefe699d1 (patch) | |
| tree | fcf35c5baa6d1cae91ad16c58fe8f6f1d9549efd /tests/unit_tests/completion_test.coffee | |
| parent | 7d7efb77270c6cd9527e788bdae9a862ced59d81 (diff) | |
| download | vimium-a61de15c2f21e2a27f09b088dea09c1cefe699d1.tar.bz2 | |
Tabs order; add tests.
Diffstat (limited to 'tests/unit_tests/completion_test.coffee')
| -rw-r--r-- | tests/unit_tests/completion_test.coffee | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/unit_tests/completion_test.coffee b/tests/unit_tests/completion_test.coffee index 811436a9..ee758dbb 100644 --- a/tests/unit_tests/completion_test.coffee +++ b/tests/unit_tests/completion_test.coffee @@ -1,8 +1,8 @@ require "./test_helper.js" extend(global, require "../../lib/utils.js") extend(global, require "../../background_scripts/completion.js") +extend global, require "./test_chrome_stubs.js" -global.chrome = {} global.document = createElement: -> {} @@ -399,6 +399,24 @@ context "RegexpCache", should "search for a string with a prefix/suffix (negative case)", -> assert.isTrue "hound dog".search(RegexpCache.get("do", "\\b", "\\b")) == -1 +context "TabRecency", + setup -> + @tabRecency = new TabRecency() + @tabRecency.add 3 + @tabRecency.add 2 + @tabRecency.add 1 + @tabRecency.add 4 + + 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 + assert.isTrue @tabRecency.recencyScore(2) < @tabRecency.recencyScore 1 + + should "give a low score to the current tab", -> + assert.isTrue @tabRecency.recencyScore(1) > @tabRecency.recencyScore 4 + assert.isTrue @tabRecency.recencyScore(2) > @tabRecency.recencyScore 4 + assert.isTrue @tabRecency.recencyScore(3) > @tabRecency.recencyScore 4 + # A convenience wrapper around completer.filter() so it can be called synchronously in tests. filterCompleter = (completer, queryTerms) -> results = [] |
