aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit_tests
diff options
context:
space:
mode:
authorStephen Blott2015-05-17 13:24:46 +0100
committerStephen Blott2015-05-17 13:24:50 +0100
commit904398308debad22fedec227ec8e71adb2bc5720 (patch)
treecf205e6a3f09f889a4c1f25e60fd1742780da945 /tests/unit_tests
parent6387f2e89774c1af7494f8507dfcc1fa245f2524 (diff)
downloadvimium-904398308debad22fedec227ec8e71adb2bc5720.tar.bz2
TabToOpen: respect trailing options when extracting query terms.
A custom search engine like this... i: https://www.google.ie/search?q=%s&num=30&newwindow=1&biw=1918&bih=1015&tbm=isch Google image search Should not match a URL like this... https://www.google.ie/search?q=bbc+sport
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/utils_test.coffee10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee
index 829c7042..9d71cc49 100644
--- a/tests/unit_tests/utils_test.coffee
+++ b/tests/unit_tests/utils_test.coffee
@@ -49,6 +49,16 @@ context "convertToUrl",
assert.equal "https://www.google.com/search?q=go+ogle.com", Utils.convertToUrl("go ogle.com")
assert.equal "https://www.google.com/search?q=%40twitter", Utils.convertToUrl("@twitter")
+context "extractQuery",
+ should "extract queries from search URLs", ->
+ assert.equal "bbc sport 1", Utils.extractQuery "https://www.google.ie/search?q=%s", "https://www.google.ie/search?q=bbc+sport+1"
+ assert.equal "bbc sport 2", Utils.extractQuery "http://www.google.ie/search?q=%s", "https://www.google.ie/search?q=bbc+sport+2"
+ assert.equal "bbc sport 3", Utils.extractQuery "https://www.google.ie/search?q=%s", "http://www.google.ie/search?q=bbc+sport+3"
+ assert.equal "bbc sport 4", Utils.extractQuery "https://www.google.ie/search?q=%s", "http://www.google.ie/search?q=bbc+sport+4&blah"
+
+ should "extract not queries from incorrect search URLs", ->
+ assert.isFalse Utils.extractQuery "https://www.google.ie/search?q=%s&foo=bar", "https://www.google.ie/search?q=bbc+sport"
+
context "hasChromePrefix",
should "detect chrome prefixes of URLs", ->
assert.isTrue Utils.hasChromePrefix "about:foobar"