fixed objectCollection not leaving a journal entry on removal
This commit is contained in:
parent
e0d9a71322
commit
6877008017
2 changed files with 36 additions and 10 deletions
|
|
@ -16,7 +16,7 @@ import {
|
|||
VERSION,
|
||||
} from 'src/stores/sync_config.js'
|
||||
|
||||
describe.skip('The SyncConfig module', () => {
|
||||
describe('The SyncConfig module', () => {
|
||||
beforeEach(() => {
|
||||
setActivePinia(createPinia())
|
||||
})
|
||||
|
|
@ -30,7 +30,7 @@ describe.skip('The SyncConfig module', () => {
|
|||
|
||||
it('should initialize storage if none present', () => {
|
||||
const store = useSyncConfigStore()
|
||||
store.setSyncConfig(store, user)
|
||||
store.setSyncConfig({ ...user })
|
||||
expect(store.cache._version).to.eql(VERSION)
|
||||
expect(store.cache._timestamp).to.be.a('number')
|
||||
expect(store.cache.flagStorage).to.eql(defaultState.flagStorage)
|
||||
|
|
@ -95,7 +95,7 @@ describe.skip('The SyncConfig module', () => {
|
|||
expect(store.cache.flagStorage.updateCounter).to.eql(999)
|
||||
})
|
||||
|
||||
it('should remote version if local missing', () => {
|
||||
it('should use remote version if local missing', () => {
|
||||
const store = useSyncConfigStore()
|
||||
store.setSyncConfig(store, user)
|
||||
expect(store.cache._version).to.eql(VERSION)
|
||||
|
|
@ -127,14 +127,26 @@ describe.skip('The SyncConfig module', () => {
|
|||
path: 'objectCollections.testing',
|
||||
value: { _key: 'a', foo: 1 },
|
||||
})
|
||||
expect(store.prefsStorage.objectCollections.testing).to.eql({
|
||||
data: { a: { _key: 'a', foo: 1 } },
|
||||
index: ['a'],
|
||||
})
|
||||
store.removeCollectionPreference({
|
||||
path: 'collections.testing',
|
||||
value: 2,
|
||||
})
|
||||
store.removeCollectionPreference({
|
||||
path: 'objectCollections.testing',
|
||||
value: { _key: 'a' },
|
||||
})
|
||||
store.updateCache({ username: 'test' })
|
||||
expect(store.prefsStorage.simple.testing).to.eql(2)
|
||||
expect(store.prefsStorage.collections.testing).to.eql([])
|
||||
expect(store.prefsStorage._journal.length).to.eql(2)
|
||||
expect(store.prefsStorage.objectCollections.testing).to.eql({
|
||||
data: {},
|
||||
index: [],
|
||||
})
|
||||
expect(store.prefsStorage._journal.length).to.eql(3)
|
||||
expect(store.prefsStorage._journal[0]).to.eql({
|
||||
path: 'simple.testing',
|
||||
operation: 'set',
|
||||
|
|
@ -152,7 +164,7 @@ describe.skip('The SyncConfig module', () => {
|
|||
expect(store.prefsStorage._journal[2]).to.eql({
|
||||
path: 'objectCollections.testing',
|
||||
operation: 'removeFromCollection',
|
||||
args: [{ _key: 'a', foo: 1 }],
|
||||
args: [{ _key: 'a' }],
|
||||
// should have A timestamp, we don't really care what it is
|
||||
timestamp: store.prefsStorage._journal[2].timestamp,
|
||||
})
|
||||
|
|
@ -179,7 +191,7 @@ describe.skip('The SyncConfig module', () => {
|
|||
data: { a: { _key: 'a', foo: 1 } },
|
||||
index: ['a'],
|
||||
})
|
||||
expect(store.prefsStorage._journal.length).to.eql(3)
|
||||
expect(store.prefsStorage._journal.length).to.eql(4)
|
||||
})
|
||||
|
||||
it('should remove depth = 3 set/unset entries from journal', () => {
|
||||
Loading…
Add table
Add a link
Reference in a new issue