aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorStephen Blott2015-06-17 05:08:03 +0100
committerStephen Blott2015-06-17 05:53:01 +0100
commit8ff1aef751a533c17e683207dae1eb165b210f92 (patch)
treef1614099efdb8b297656576dcf4855b4a0d1c86d /tests
parentaa00e29dc2533b6701c65935223599671c5833b1 (diff)
downloadvimium-8ff1aef751a533c17e683207dae1eb165b210f92.tar.bz2
Fix non-default front-end settings.
(@mrmr1993: This is yet another approach to the Settings problem.) With the new Settings implemetation, settings which have a non-default value and which are not in synced storage (that is, they have not been changed since synced storage was introduced) are not currently accessible to content scripts. This commit makes such settings accessible via chrome.storage.local. Important: - There's a change to the established settings data model here. Previously, settings with default values were not stored; here, they are. This eliminates a considerable amount logic from Settings, but means that migrations will be required if default values are changed in future. (Other than type changes, have we ever changed a default value?) - There's also a change (bug fix?) to the behaviour when an affected setting is reset to its default value. Previously, the change would *not* have been synced (whereas all other changes are). Here, such changes *are* synced. The previous behaviour was inconsistent with the syncing behaviour of all other options changes. Note: - This isn't particularly well tested. It's being committed mainly just for consideration of the approach, initially.
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/settings_test.coffee12
-rw-r--r--tests/unit_tests/test_chrome_stubs.coffee6
2 files changed, 6 insertions, 12 deletions
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: