aboutsummaryrefslogtreecommitdiffstats
path: root/tests/unit_tests
diff options
context:
space:
mode:
authormike-work2014-05-07 23:57:56 +0100
committermike-work2014-05-29 02:42:51 +0100
commita18ad484f2fdc0019c15d94405c915f8bfe6d76f (patch)
tree3a8667096504d09b85ac0cd1cf4135763c95e375 /tests/unit_tests
parent1aa7ba3a5810742d14edfb738120b70f4a0f7619 (diff)
downloadvimium-a18ad484f2fdc0019c15d94405c915f8bfe6d76f.tar.bz2
Adding in search engines feature to fix #1009
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/completion_test.coffee14
-rw-r--r--tests/unit_tests/settings_test.coffee9
2 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit_tests/completion_test.coffee b/tests/unit_tests/completion_test.coffee
index fb267f63..43ecb49d 100644
--- a/tests/unit_tests/completion_test.coffee
+++ b/tests/unit_tests/completion_test.coffee
@@ -209,6 +209,20 @@ context "tab completer",
assert.arrayEqual ["tab2.com"], results.map (tab) -> tab.url
assert.arrayEqual [2], results.map (tab) -> tab.tabId
+context "search engines",
+ setup ->
+ searchEngines = "foo: bar?q=%s\n# comment\nbaz: qux?q=%s"
+ Settings.set 'searchEngines', searchEngines
+ @completer = new SearchEngineCompleter()
+ # note, I couldn't just call @completer.refresh() here as I couldn't set root.Settings without errors
+ # workaround is below, would be good for someone that understands the testing system better than me to improve
+ @completer.searchEngines = Settings.getSearchEngines()
+
+ should "return search engine suggestion", ->
+ results = filterCompleter(@completer, ["foo", "hello"])
+ assert.arrayEqual ["bar?q=hello"], results.map (result) -> result.url
+ assert.arrayEqual ["foo: hello"], results.map (result) -> result.title
+
context "suggestions",
should "escape html in page titles", ->
suggestion = new Suggestion(["queryterm"], "tab", "url", "title <span>", returns(1))
diff --git a/tests/unit_tests/settings_test.coffee b/tests/unit_tests/settings_test.coffee
index 25bb3628..1283497c 100644
--- a/tests/unit_tests/settings_test.coffee
+++ b/tests/unit_tests/settings_test.coffee
@@ -70,5 +70,14 @@ context "settings",
chrome.storage.sync.set { scrollStepSize: JSON.stringify(message) }
assert.equal message, Sync.message
+ should "set search engines, retrieve them correctly and check that it has been parsed correctly", ->
+ searchEngines = "foo: bar?q=%s\n# comment\nbaz: qux?q=%s"
+ parsedSearchEngines = {"foo": "bar?q=%s", "baz": "qux?q=%s"}
+ Settings.set 'searchEngines', searchEngines
+ assert.equal(searchEngines, Settings.get('searchEngines'))
+ result = Settings.getSearchEngines()
+ assert.isTrue(parsedSearchEngines["foo"] == result["foo"] &&
+ parsedSearchEngines["baz"] == result["baz"] && Object.keys(result).length == 2)
+
should "sync a key which is not a known setting (without crashing)", ->
chrome.storage.sync.set { notASetting: JSON.stringify("notAUsefullValue") }