aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephen Blott2016-03-27 10:20:37 +0100
committerStephen Blott2016-03-27 10:22:58 +0100
commit6af7cae45c498628c7052116cedccc369e9fbe64 (patch)
tree21d00b2144105fe141e6a1832b5a5913d3bb6961 /tests
parent824ab0dc6bd8bec3c75834b736360276877dd74c (diff)
downloadvimium-6af7cae45c498628c7052116cedccc369e9fbe64.tar.bz2
Add test for extractQuery().
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/utils_test.coffee16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee
index fa35be97..62471949 100644
--- a/tests/unit_tests/utils_test.coffee
+++ b/tests/unit_tests/utils_test.coffee
@@ -156,3 +156,19 @@ context "escapeRegexSpecialCharacters",
regexp = new RegExp Utils.escapeRegexSpecialCharacters str
assert.isTrue regexp.test str
+context "extractQuery",
+ should "extract the query terms from a URL", ->
+ url = "https://www.google.ie/search?q=star+wars&foo&bar"
+ searchUrl = "https://www.google.ie/search?q=%s"
+ assert.equal "star wars", Utils.extractQuery searchUrl, url
+
+ should "require trailing URL components", ->
+ url = "https://www.google.ie/search?q=star+wars&foo&bar"
+ searchUrl = "https://www.google.ie/search?q=%s&foobar=x"
+ assert.equal null, Utils.extractQuery searchUrl, url
+
+ should "accept trailing URL components", ->
+ url = "https://www.google.ie/search?q=star+wars&foo&bar&foobar=x"
+ searchUrl = "https://www.google.ie/search?q=%s&foobar=x"
+ assert.equal "star wars", Utils.extractQuery searchUrl, url
+