aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit_tests/utils_test.coffee
diff options
context:
space:
mode:
authorJez Ng2012-09-03 23:19:35 -0400
committerJez Ng2012-09-08 04:30:26 -0400
commit6df16c591219d87058b4c48682d503382e44693f (patch)
tree3ec4044a51c557cd59df6d6a9ff712e6491a9c18 /tests/unit_tests/utils_test.coffee
parent8437dd96144475343562c9a6aa2f14469bc75a56 (diff)
downloadvimium-6df16c591219d87058b4c48682d503382e44693f.tar.bz2
Set up PhantomJS testing.
Diffstat (limited to 'tests/unit_tests/utils_test.coffee')
-rw-r--r--tests/unit_tests/utils_test.coffee20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/unit_tests/utils_test.coffee b/tests/unit_tests/utils_test.coffee
new file mode 100644
index 00000000..6a44b460
--- /dev/null
+++ b/tests/unit_tests/utils_test.coffee
@@ -0,0 +1,20 @@
+require "./test_helper.js"
+extend(global, require "../../lib/utils.js")
+
+context "convertToUrl",
+ should "detect and clean up valid URLs", ->
+ assert.equal "http://www.google.com/", Utils.convertToUrl("http://www.google.com/")
+ assert.equal "http://www.google.com/", Utils.convertToUrl(" http://www.google.com/ ")
+ assert.equal "http://www.google.com", Utils.convertToUrl("www.google.com")
+ assert.equal "http://google.com", Utils.convertToUrl("google.com")
+ assert.equal "http://localhost", Utils.convertToUrl("localhost")
+ assert.equal "http://xyz.museum", Utils.convertToUrl("xyz.museum")
+ assert.equal "chrome://extensions", Utils.convertToUrl("chrome://extensions")
+ assert.equal "http://user:pass@ftp.xyz.com/test", Utils.convertToUrl("user:pass@ftp.xyz.com/test")
+ assert.equal "http://127.0.0.1", Utils.convertToUrl("127.0.0.1")
+ assert.equal "http://127.0.0.1:8080", Utils.convertToUrl("127.0.0.1:8080")
+ assert.equal "http://[::]:8080", Utils.convertToUrl("[::]:8080")
+
+ 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")