aboutsummaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2022-08-16 19:24:20 +0300
committerHenry Jameson <me@hjkos.com>2022-08-16 19:24:45 +0300
commit840ce063971d68063d380fc5f3aacc0564363b50 (patch)
treec3cf81569689285657e76192af2f010b1e341d62 /test/unit
parent8d6e5c1e69b32bc6c13558dc4346407662849486 (diff)
proper journal trimming + remove some old workaround to my local bad data
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/specs/modules/serverSideStorage.spec.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/test/unit/specs/modules/serverSideStorage.spec.js b/test/unit/specs/modules/serverSideStorage.spec.js
index f10e21e6..7adce20d 100644
--- a/test/unit/specs/modules/serverSideStorage.spec.js
+++ b/test/unit/specs/modules/serverSideStorage.spec.js
@@ -107,7 +107,7 @@ describe('The serverSideStorage module', () => {
})
})
describe('setPreference', () => {
- const { setPreference, updateCache } = mutations
+ const { setPreference, updateCache, addToCollection, removeFromCollection } = mutations
it('should set preference and update journal log accordingly', () => {
const state = cloneDeep(defaultState)
@@ -123,12 +123,15 @@ describe('The serverSideStorage module', () => {
})
})
- it('should keep journal to a minimum (one entry per path for sets)', () => {
+ it('should keep journal to a minimum', () => {
const state = cloneDeep(defaultState)
setPreference(state, { path: 'simple.testing', value: 1 })
setPreference(state, { path: 'simple.testing', value: 2 })
+ addToCollection(state, { path: 'collections.testing', value: 2 })
+ removeFromCollection(state, { path: 'collections.testing', value: 2 })
updateCache(state, { username: 'test' })
expect(state.prefsStorage.simple.testing).to.eql(2)
+ expect(state.prefsStorage.collections.testing).to.eql([])
expect(state.prefsStorage._journal.length).to.eql(1)
expect(state.prefsStorage._journal[0]).to.eql({
path: 'simple.testing',
@@ -137,6 +140,14 @@ describe('The serverSideStorage module', () => {
// should have A timestamp, we don't really care what it is
timestamp: state.prefsStorage._journal[0].timestamp
})
+ expect(state.prefsStorage._journal[1]).to.eql({
+ path: 'collection.testing',
+ operation: 'remove',
+ args: [2],
+ // should have A timestamp, we don't really care what it is
+ timestamp: state.prefsStorage._journal[1].timestamp
+ })
+ })
})
})
})