diff options
| author | Henry Jameson <me@hjkos.com> | 2022-08-10 02:31:41 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2022-08-10 02:37:09 +0300 |
| commit | 2c0eb29b286edf57d75c6044855ea5be9187493b (patch) | |
| tree | b628aa739d4f52249743f25135c7a3fc5c8d9b2e /test/unit/specs | |
| parent | aa41cedd932e88b030ecc3cc54848b5aa300eec3 (diff) | |
more prefs storage work + move dontShowUpdateNotifs to prefs
Diffstat (limited to 'test/unit/specs')
| -rw-r--r-- | test/unit/specs/modules/serverSideStorage.spec.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/unit/specs/modules/serverSideStorage.spec.js b/test/unit/specs/modules/serverSideStorage.spec.js index 6059dc84..da790793 100644 --- a/test/unit/specs/modules/serverSideStorage.spec.js +++ b/test/unit/specs/modules/serverSideStorage.spec.js @@ -105,6 +105,38 @@ describe('The serverSideStorage module', () => { expect(state.cache.flagStorage).to.eql(defaultState.flagStorage) }) }) + describe('setPreference', () => { + const { setPreference } = mutations + + it('should set preference and update journal log accordingly', () => { + const state = cloneDeep(defaultState) + setPreference(state, { path: 'simple.testing', value: 1 }) + expect(state.prefsStorage.simple.testing).to.eql(1) + expect(state.prefsStorage._journal.length).to.eql(1) + expect(state.prefsStorage._journal[0]).to.eql({ + path: 'simple.testing', + command: 'set', + args: [1], + // should have A timestamp, we don't really care what it is + timestamp: state.prefsStorage._journal[0].timestamp + }) + }) + + it('should keep journal to a minimum (one entry per path)', () => { + const state = cloneDeep(defaultState) + setPreference(state, { path: 'simple.testing', value: 1 }) + setPreference(state, { path: 'simple.testing', value: 2 }) + expect(state.prefsStorage.simple.testing).to.eql(1) + expect(state.prefsStorage._journal.length).to.eql(1) + expect(state.prefsStorage._journal[0]).to.eql({ + path: 'simple.testing', + command: 'set', + args: [2], + // should have A timestamp, we don't really care what it is + timestamp: state.prefsStorage._journal[0].timestamp + }) + }) + }) }) describe('helper functions', () => { |
