proper journal trimming + remove some old workaround to my local bad data
This commit is contained in:
parent
e96af9769d
commit
d479a0a01b
2 changed files with 39 additions and 22 deletions
|
|
@ -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
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue