aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephen Blott2014-12-30 12:21:29 +0000
committerStephen Blott2014-12-30 12:21:29 +0000
commit318fc7aac682b8314d34a90590061c2af11cf3aa (patch)
treef542d5579521efd69c70f66fea33c2f029f2574e /tests
parent774915f3967655ab800cc3c1ac73f0746618d3de (diff)
parent3620fec662ab89bd4f7827e66deec49ff4d11b8e (diff)
downloadvimium-318fc7aac682b8314d34a90590061c2af11cf3aa.tar.bz2
Merge branch 'master' into post-1.46
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/exclusion_test.coffee50
-rw-r--r--tests/unit_tests/utils_test.coffee3
2 files changed, 19 insertions, 34 deletions
diff --git a/tests/unit_tests/exclusion_test.coffee b/tests/unit_tests/exclusion_test.coffee
index 25bd8125..b3ed7194 100644
--- a/tests/unit_tests/exclusion_test.coffee
+++ b/tests/unit_tests/exclusion_test.coffee
@@ -25,49 +25,33 @@ extend(global, require "../../background_scripts/main.js")
#
context "Excluded URLs and pass keys",
- # These tests have no setup, they use the default values from settings.coffee.
+ setup ->
+ Exclusions.postUpdateHook(
+ [
+ { pattern: "http*://mail.google.com/*", passKeys: "" }
+ { pattern: "http*://www.facebook.com/*", passKeys: "abab" }
+ { pattern: "http*://www.facebook.com/*", passKeys: "cdcd" }
+ { pattern: "http*://www.bbc.com/*", passKeys: "" }
+ { pattern: "http*://www.bbc.com/*", passKeys: "ab" }
+ ])
should "be disabled for excluded sites", ->
- rule = isEnabledForUrl({ url: 'http://www.google.com/calendar/page' })
- assert.isFalse rule.isEnableForUrl
+ rule = isEnabledForUrl({ url: 'http://mail.google.com/calendar/page' })
+ assert.isFalse rule.isEnabledForUrl
assert.isFalse rule.passKeys
- should "be enabled, but with pass keys", ->
- rule = isEnabledForUrl({ url: 'https://www.facebook.com/something' })
- assert.isTrue rule.isEnabledForUrl
+ should "be disabled for excluded sites, one exclusion", ->
+ rule = isEnabledForUrl({ url: 'http://www.bbc.com/calendar/page' })
+ assert.isFalse rule.isEnabledForUrl
assert.isFalse rule.passKeys
- addExclusionRule("http*://www.facebook.com/*","oO")
+
+ should "be enabled, but with pass keys", ->
rule = isEnabledForUrl({ url: 'https://www.facebook.com/something' })
assert.isTrue rule.isEnabledForUrl
- assert.equal rule.passKeys, 'oO'
+ assert.equal rule.passKeys, 'abcd'
should "be enabled", ->
rule = isEnabledForUrl({ url: 'http://www.twitter.com/pages' })
assert.isTrue rule.isEnabledForUrl
assert.isFalse rule.passKeys
- should "add a new excluded URL", ->
- rule = isEnabledForUrl({ url: 'http://www.example.com/page' })
- assert.isTrue rule.isEnabledForUrl
- addExclusionRule("http://www.example.com*")
- rule = isEnabledForUrl({ url: 'http://www.example.com/page' })
- assert.isFalse rule.isEnabledForUrl
- assert.isFalse rule.passKeys
-
- should "add a new excluded URL with passkeys", ->
- rule = isEnabledForUrl({ url: 'http://www.anotherexample.com/page' })
- assert.isTrue rule.isEnabledForUrl
- addExclusionRule("http://www.anotherexample.com/*","jk")
- rule = isEnabledForUrl({ url: 'http://www.anotherexample.com/page' })
- assert.isTrue rule.isEnabledForUrl
- assert.equal rule.passKeys, 'jk'
-
- should "update an existing excluded URL with passkeys", ->
- rule = isEnabledForUrl({ url: 'http://mail.google.com/page' })
- assert.isFalse rule.isEnabledForUrl
- assert.isFalse rule.passKeys
- addExclusionRule("http*://mail.google.com/*","jknp")
- rule = isEnabledForUrl({ url: 'http://mail.google.com/page' })
- assert.isTrue rule.isEnabledForUrl
- assert.equal rule.passKeys, 'jknp'
-
diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee
index 556f5b7a..88e9a15b 100644
--- a/tests/unit_tests/utils_test.coffee
+++ b/tests/unit_tests/utils_test.coffee
@@ -45,7 +45,8 @@ context "convertToUrl",
should "convert non-URL terms into search queries", ->
assert.equal "http://www.google.com/search?q=google", Utils.convertToUrl("google")
- assert.equal "http://www.google.com/search?q=go%20ogle.com", Utils.convertToUrl("go ogle.com")
+ assert.equal "http://www.google.com/search?q=go+ogle.com", Utils.convertToUrl("go ogle.com")
+ assert.equal "http://www.google.com/search?q=%40twitter", Utils.convertToUrl("@twitter")
context "hasChromePrefix",
should "detect chrome prefixes of URLs", ->