diff options
| author | Stephen Blott | 2014-04-19 10:02:14 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2014-04-19 10:02:14 +0100 | 
| commit | 5ea93cd18611d859867bdd80c44c886d29a7b958 (patch) | |
| tree | d8cde4be68d9c2ae2e0d73d6d8ebfd9eced52e04 /tests/unit_tests | |
| parent | a2de5078f8d34c2b65b451556aff07a6a41399a5 (diff) | |
| download | vimium-5ea93cd18611d859867bdd80c44c886d29a7b958.tar.bz2 | |
Add remote sync test for setting cleared.
Diffstat (limited to 'tests/unit_tests')
| -rw-r--r-- | tests/unit_tests/settings_test.coffee | 9 | ||||
| -rw-r--r-- | tests/unit_tests/test_chrome_stubs.coffee | 9 | 
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)  | 
