π¬ A browser extension and desktop app that turns your clicks into step-by-step guides with annotated screenshots π
TypeScript browser-extensionchrome-extensiondocumentationfirefox-extensionguide-generatorlocal-firstmanifest-v3privacy-firstproductivityreactscreenshotstep-by-step-guidetutorialtypescriptworkflowwxt
test(core): cover swapping the guide store
Luis Ortiz01f71090a6ad
diff --git a/packages/core/src/guides/__tests__/store.test.ts b/packages/core/src/guides/__tests__/store.test.tsnew file mode 100644index 0000000..8f7ec9e--- /dev/null+++ b/packages/core/src/guides/__tests__/store.test.ts@@ -0,0 +1,37 @@+import { beforeEach, describe, expect, it } from 'vitest';+import { dexieStore } from '../dexie-store';+import { createGuide, getGuides } from '../service';+import { configureStore, resetStore, store } from '../store';+import type { Guide } from '../types';++const sentinel = { id: 'from-another-store', title: 'elsewhere' } as Guide;++describe('a second store behind the service', () => {+ beforeEach(() => resetStore());++ it('serves shared reads from whatever store is configured', async () => {+ configureStore({ ...dexieStore, getGuides: async () => [sentinel] });+ expect(await getGuides()).toEqual([sentinel]);+ });++ it('serves shared writes from that store too', async () => {+ const written: string[] = [];+ configureStore({+ ...dexieStore,+ createGuide: async (id: string) => {+ written.push(id);+ return sentinel;+ },+ });+ await createGuide('abc');+ expect(written).toEqual(['abc']);+ });++ it('goes back to the browser store when reset', () => {+ const other = { ...dexieStore, getGuides: async () => [sentinel] };+ configureStore(other);+ expect(store.getGuides).toBe(other.getGuides);+ resetStore();+ expect(store.getGuides).toBe(dexieStore.getGuides);+ });+});