Open source personal finance application
test(stores): align empty-emission tests with the cache-first guard
Ilya Komichevb385bd03cdf4
diff --git a/app/app/components/categories/useCategoriesStore.test.ts b/app/app/components/categories/useCategoriesStore.test.tsindex 8a51f92b..26841d4e 100644--- a/app/app/components/categories/useCategoriesStore.test.ts+++ b/app/app/components/categories/useCategoriesStore.test.ts@@ -75,8 +75,9 @@ describe('useCategoriesStore', () => {expect(store.items.c1).toMatchObject({ icon: 'mdi:cat' })expect(store.items.adjustment).toBeDefined() // synthetic re-added+ // TEMP: cache-first guard - an empty emission must not wipe primed/cached items.h.watchCallbacks[0]!([])- expect(store.hasItems).toBe(false)+ expect(store.hasItems).toBe(true)expect(store.items.transfer).toBeDefined()})diff --git a/app/app/components/trns/useTrnsStore.test.ts b/app/app/components/trns/useTrnsStore.test.tsindex 098a5dad..7b2ff44e 100644--- a/app/app/components/trns/useTrnsStore.test.ts+++ b/app/app/components/trns/useTrnsStore.test.ts@@ -68,7 +68,8 @@ describe('useTrnsStore', () => {expect(store.items?.a).toMatchObject({ amount: 100, categoryId: 'food', type: 0 })})- it('sets items to null when the snapshot empties', () => {+ // TEMP: cache-first guard - an empty emission must not wipe primed/cached items.+ it('keeps existing items on an empty emission', () => {const store = useTrnsStore()store.initTrns()const emit = h.watchCallbacks[0]!@@ -77,7 +78,7 @@ describe('useTrnsStore', () => {expect(store.items?.a).toBeDefined()emit([])- expect(store.items).toBeNull()+ expect(store.items?.a).toBeDefined()})it('does not subscribe in demo mode', () => {diff --git a/app/app/components/wallets/useWalletsStore.test.ts b/app/app/components/wallets/useWalletsStore.test.tsindex 92e51ec5..b25f0adb 100644--- a/app/app/components/wallets/useWalletsStore.test.ts+++ b/app/app/components/wallets/useWalletsStore.test.ts@@ -68,8 +68,9 @@ describe('useWalletsStore', () => {expect(Object.keys(store.items ?? {})).toEqual(['a', 'b'])expect(store.items?.a).toMatchObject({ currency: 'USD', type: 'cash' })+ // TEMP: cache-first guard - an empty emission must not wipe primed/cached items.h.watchCallbacks[0]!([])- expect(store.items).toBeNull()+ expect(Object.keys(store.items ?? {})).toEqual(['a', 'b'])})it('flips isLoaded on the first emission and resets it on re-subscribe', () => {