aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephen Blott2014-12-30 16:14:23 +0000
committerStephen Blott2014-12-30 16:14:23 +0000
commit214ecb92caa8fc5a71dd3cac70a7280e1de08ccd (patch)
treebd8312058bd452828dd405d481caae7f8a7f00c3 /tests
parent8f998f5b4cd1d8600b62ae7faac8afb91c4d2dab (diff)
parent74b5c1a9bb54bbc2a2c9d30925d514e02a5515f7 (diff)
downloadvimium-214ecb92caa8fc5a71dd3cac70a7280e1de08ccd.tar.bz2
Merge branch 'search-engine-descriptions' of https://github.com/smblott-github/vimium into smblott-github-search-engine-descriptions
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/completion_test.coffee11
-rw-r--r--tests/unit_tests/settings_test.coffee13
2 files changed, 16 insertions, 8 deletions
diff --git a/tests/unit_tests/completion_test.coffee b/tests/unit_tests/completion_test.coffee
index e4966016..b7b73cc2 100644
--- a/tests/unit_tests/completion_test.coffee
+++ b/tests/unit_tests/completion_test.coffee
@@ -233,17 +233,24 @@ context "tab completer",
context "search engines",
setup ->
- searchEngines = "foo: bar?q=%s\n# comment\nbaz: qux?q=%s"
+ searchEngines = "foo: bar?q=%s\n# comment\nbaz: qux?q=%s baz description"
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", ->
+ should "return search engine suggestion without description", ->
results = filterCompleter(@completer, ["foo", "hello"])
assert.arrayEqual ["bar?q=hello"], results.map (result) -> result.url
assert.arrayEqual ["foo: hello"], results.map (result) -> result.title
+ assert.arrayEqual ["search"], results.map (result) -> result.type
+
+ should "return search engine suggestion with description", ->
+ results = filterCompleter(@completer, ["baz", "hello"])
+ assert.arrayEqual ["qux?q=hello"], results.map (result) -> result.url
+ assert.arrayEqual ["hello"], results.map (result) -> result.title
+ assert.arrayEqual ["baz description"], results.map (result) -> result.type
context "suggestions",
should "escape html in page titles", ->
diff --git a/tests/unit_tests/settings_test.coffee b/tests/unit_tests/settings_test.coffee
index 4625457b..afe862a4 100644
--- a/tests/unit_tests/settings_test.coffee
+++ b/tests/unit_tests/settings_test.coffee
@@ -70,14 +70,15 @@ 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"}
+ should "set search engines, retrieve them correctly and check that they have been parsed correctly", ->
+ searchEngines = "foo: bar?q=%s\n# comment\nbaz: qux?q=%s baz description"
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)
+ assert.equal Object.keys(result).length, 2
+ assert.equal "bar?q=%s", result["foo"].url
+ assert.isFalse result["foo"].description
+ assert.equal "qux?q=%s", result["baz"].url
+ assert.equal "baz description", result["baz"].description
should "sync a key which is not a known setting (without crashing)", ->
chrome.storage.sync.set { notASetting: JSON.stringify("notAUsefullValue") }