aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephen Blott2015-06-25 05:09:36 +0100
committerStephen Blott2015-06-25 05:09:36 +0100
commite5faeff7d48a206a080a56a6541963d2d3c86da7 (patch)
tree751d29c6c499bf1325a20539b171829586a9b706 /tests
parent39e10495709eeafd972a8b66ee741bf25deee7e5 (diff)
parentaa08e16e6613d5a3760761ab89557df41a50f784 (diff)
downloadvimium-e5faeff7d48a206a080a56a6541963d2d3c86da7.tar.bz2
Merge branch 'store-all-settings' into hud-iframe-input-with-store-all-settings
Diffstat (limited to 'tests')
-rw-r--r--tests/dom_tests/dom_tests.coffee27
-rw-r--r--tests/unit_tests/settings_test.coffee12
-rw-r--r--tests/unit_tests/test_chrome_stubs.coffee6
3 files changed, 23 insertions, 22 deletions
diff --git a/tests/dom_tests/dom_tests.coffee b/tests/dom_tests/dom_tests.coffee
index dd2f5a5d..a79735ae 100644
--- a/tests/dom_tests/dom_tests.coffee
+++ b/tests/dom_tests/dom_tests.coffee
@@ -212,11 +212,14 @@ context "Filtered link hints",
@linkHints.deactivateMode()
should "label the images", ->
- hintMarkers = getHintMarkers()
- assert.equal "1: alt text", hintMarkers[0].textContent.toLowerCase()
- assert.equal "2: some title", hintMarkers[1].textContent.toLowerCase()
- assert.equal "3: alt text", hintMarkers[2].textContent.toLowerCase()
- assert.equal "4", hintMarkers[3].textContent.toLowerCase()
+ hintMarkers = getHintMarkers().map (marker) -> marker.textContent.toLowerCase()
+ # We don't know the actual hint numbers which will be assigned, so we replace them with "N".
+ hintMarkers = hintMarkers.map (str) -> str.replace /^[1-4]/, "N"
+ assert.equal 4, hintMarkers.length
+ assert.isTrue "N: alt text" in hintMarkers
+ assert.isTrue "N: some title" in hintMarkers
+ assert.isTrue "N: alt text" in hintMarkers
+ assert.isTrue "N" in hintMarkers
context "Input hints",
@@ -235,11 +238,15 @@ context "Filtered link hints",
should "label the input elements", ->
hintMarkers = getHintMarkers()
- assert.equal "1", hintMarkers[0].textContent.toLowerCase()
- assert.equal "2", hintMarkers[1].textContent.toLowerCase()
- assert.equal "3: a label", hintMarkers[2].textContent.toLowerCase()
- assert.equal "4: a label", hintMarkers[3].textContent.toLowerCase()
- assert.equal "5", hintMarkers[4].textContent.toLowerCase()
+ hintMarkers = getHintMarkers().map (marker) -> marker.textContent.toLowerCase()
+ # We don't know the actual hint numbers which will be assigned, so we replace them with "N".
+ hintMarkers = hintMarkers.map (str) -> str.replace /^[1-5]/, "N"
+ assert.equal 5, hintMarkers.length
+ assert.isTrue "N" in hintMarkers
+ assert.isTrue "N" in hintMarkers
+ assert.isTrue "N: a label" in hintMarkers
+ assert.isTrue "N: a label" in hintMarkers
+ assert.isTrue "N" in hintMarkers
context "Input focus",
diff --git a/tests/unit_tests/settings_test.coffee b/tests/unit_tests/settings_test.coffee
index 08145190..6270ae3e 100644
--- a/tests/unit_tests/settings_test.coffee
+++ b/tests/unit_tests/settings_test.coffee
@@ -27,12 +27,6 @@ context "settings",
Settings.set 'scrollStepSize', 20
assert.equal Settings.get('scrollStepSize'), 20
- should "not store values equal to the default", ->
- Settings.set 'scrollStepSize', 20
- assert.isTrue Settings.has 'scrollStepSize'
- Settings.set 'scrollStepSize', 60
- assert.isFalse Settings.has 'scrollStepSize'
-
should "revert to defaults if no key is stored", ->
Settings.set 'scrollStepSize', 20
Settings.clear 'scrollStepSize'
@@ -55,7 +49,7 @@ context "synced settings",
Settings.set 'scrollStepSize', 20
assert.equal Settings.get('scrollStepSize'), 20
Settings.propagateChangesFromChromeStorage { scrollStepSize: { newValue: "60" } }
- assert.isFalse Settings.has 'scrollStepSize'
+ assert.equal Settings.get('scrollStepSize'), 60
should "propagate non-default values from synced storage", ->
chrome.storage.sync.set { scrollStepSize: JSON.stringify(20) }
@@ -64,12 +58,12 @@ context "synced settings",
should "propagate default values from synced storage", ->
Settings.set 'scrollStepSize', 20
chrome.storage.sync.set { scrollStepSize: JSON.stringify(60) }
- assert.isFalse Settings.has 'scrollStepSize'
+ assert.equal Settings.get('scrollStepSize'), 60
should "clear a setting from synced storage", ->
Settings.set 'scrollStepSize', 20
chrome.storage.sync.remove 'scrollStepSize'
- assert.isFalse Settings.has 'scrollStepSize'
+ assert.equal Settings.get('scrollStepSize'), 60
should "trigger a postUpdateHook", ->
message = "Hello World"
diff --git a/tests/unit_tests/test_chrome_stubs.coffee b/tests/unit_tests/test_chrome_stubs.coffee
index fe2fc298..c6a56521 100644
--- a/tests/unit_tests/test_chrome_stubs.coffee
+++ b/tests/unit_tests/test_chrome_stubs.coffee
@@ -57,9 +57,9 @@ exports.chrome =
storage:
# chrome.storage.local
local:
- get: ->
- set: ->
- remove: ->
+ get: (_, callback) -> callback?()
+ set: (_, callback) -> callback?()
+ remove: (_, callback) -> callback?()
# chrome.storage.onChanged
onChanged: