aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephen Blott2016-03-26 12:53:40 +0000
committerStephen Blott2016-03-26 13:20:51 +0000
commita1103158551ace4232b613d290f5d193a7c5185f (patch)
tree387ca18eb54814e33f670a96ecb82c8d6d0c69e8 /tests
parentbfeaeae0df589e5163cdc9e99ea9d3c3b1b15038 (diff)
downloadvimium-a1103158551ace4232b613d290f5d193a7c5185f.tar.bz2
Multiple minor tweaks.
Some of this code is showing its age, so these are just a number of minor tweaks (to keep things clear, consistent and concise). Also, add a couple of tests (while we're at it).
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/exclusion_test.coffee16
-rw-r--r--tests/unit_tests/utils_test.coffee4
2 files changed, 19 insertions, 1 deletions
diff --git a/tests/unit_tests/exclusion_test.coffee b/tests/unit_tests/exclusion_test.coffee
index 649dfd1f..54cb4ed3 100644
--- a/tests/unit_tests/exclusion_test.coffee
+++ b/tests/unit_tests/exclusion_test.coffee
@@ -15,12 +15,13 @@ root.Marks =
extend(global, require "../../lib/utils.js")
Utils.getCurrentVersion = -> '1.44'
extend(global,require "../../lib/settings.js")
+extend(global,require "../../lib/clipboard.js")
extend(global, require "../../background_scripts/exclusions.js")
extend(global, require "../../background_scripts/commands.js")
extend(global, require "../../background_scripts/main.js")
isEnabledForUrl = (request) ->
- Frames.isEnabledForUrl {request, tabId: 0, port: postMessage: (request) -> request}
+ Exclusions.isEnabledForUrl request.url
# These tests cover only the most basic aspects of excluded URLs and passKeys.
#
@@ -34,6 +35,9 @@ context "Excluded URLs and pass keys",
{ pattern: "http*://www.facebook.com/*", passKeys: "cdcd" }
{ pattern: "http*://www.bbc.com/*", passKeys: "" }
{ pattern: "http*://www.bbc.com/*", passKeys: "ab" }
+ { pattern: "http*://www.example.com/*", passKeys: "a bb c bba a" }
+ { pattern: "http*://www.duplicate.com/*", passKeys: "ace" }
+ { pattern: "http*://www.duplicate.com/*", passKeys: "bdf" }
])
should "be disabled for excluded sites", ->
@@ -56,3 +60,13 @@ context "Excluded URLs and pass keys",
assert.isTrue rule.isEnabledForUrl
assert.isFalse rule.passKeys
+ should "handle spaces and duplicates in passkeys", ->
+ rule = isEnabledForUrl({ url: 'http://www.example.com/pages' })
+ assert.isTrue rule.isEnabledForUrl
+ assert.equal "abc", rule.passKeys
+
+ should "handle multiple passkeys rules", ->
+ rule = isEnabledForUrl({ url: 'http://www.duplicate.com/pages' })
+ assert.isTrue rule.isEnabledForUrl
+ assert.equal "abcdef", rule.passKeys
+
diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee
index 9b71ca72..93849349 100644
--- a/tests/unit_tests/utils_test.coffee
+++ b/tests/unit_tests/utils_test.coffee
@@ -125,3 +125,7 @@ context "makeIdempotent",
assert.equal 1, @count
@func()
assert.equal 1, @count
+
+context "distinctCharacters",
+ should "eliminate duplicate characters", ->
+ assert.equal "abc", Utils.distinctCharacters "bbabaabbacabbbab"