aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/unit_tests/settings_test.coffee9
-rw-r--r--tests/unit_tests/test_chrome_stubs.coffee9
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/unit_tests/settings_test.coffee b/tests/unit_tests/settings_test.coffee
index 07b96a30..9aec95dd 100644
--- a/tests/unit_tests/settings_test.coffee
+++ b/tests/unit_tests/settings_test.coffee
@@ -64,3 +64,12 @@ context "settings",
# Pull Sync's version of scrollStepSize, this should delete scrollStepSize in localStorage, because it's a default value.
Sync.pull()
assert.isFalse Settings.has 'scrollStepSize'
+
+ should "remote setting cleared", ->
+ # Prime localStorage.
+ Settings.set 'scrollStepSize', 20
+ assert.equal Settings.get('scrollStepSize'), 20
+ # Prime Sync with a non-default value.
+ chrome.storage.sync.set { scrollStepSize: JSON.stringify(40) }
+ chrome.storage.sync.remove 'scrollStepSize'
+ assert.isFalse Settings.has 'scrollStepSize'
diff --git a/tests/unit_tests/test_chrome_stubs.coffee b/tests/unit_tests/test_chrome_stubs.coffee
index f32de24f..dd8dccf8 100644
--- a/tests/unit_tests/test_chrome_stubs.coffee
+++ b/tests/unit_tests/test_chrome_stubs.coffee
@@ -16,6 +16,13 @@ global.chrome.storage.onChanged ||=
if @func
@func( @mkKeyValue(key,value), 'synced storage stub' )
+ callEmpty: (key) ->
+ chrome.runtime = { lastError: undefined }
+ if @func
+ items = {}
+ items[key] = {}
+ @func( items, 'synced storage stub' )
+
mkKeyValue: (key, value) ->
obj = {}
obj[key] = { newValue: value }
@@ -53,4 +60,6 @@ global.chrome.storage.sync ||=
delete @store[key]
if callback
callback()
+ # Now, generate (supposedly asynchronous) notification for listeners.
+ global.chrome.storage.onChanged.callEmpty(key)