From 840ce063971d68063d380fc5f3aacc0564363b50 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Tue, 16 Aug 2022 19:24:20 +0300 Subject: proper journal trimming + remove some old workaround to my local bad data --- test/unit/specs/modules/serverSideStorage.spec.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'test/unit') 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 + }) + }) }) }) }) -- cgit v1.2.3-70-g09d2