[storage] CareLog: Append-only care events and the kept identity, checked against the contract

This commit is contained in:
2026-11-02 00:20:58 +01:00
parent d091c31b49
commit 2b5cd719c1
4 changed files with 217 additions and 13 deletions
+5 -5
View File
@@ -1,16 +1,16 @@
import { IDBFactory, IDBKeyRange } from 'fake-indexeddb';
import { afterEach, describe, expect, it, vi } from 'vitest';
import { asSunsetPlace, openProfile, type Profile, type SunsetPlace } from '../src/index.js';
import { asSunsetPlace, openStorage, type Storage, type SunsetPlace } from '../src/index.js';
const brno: SunsetPlace = {
kind: 'town',
town: { name: 'Brno', region: '', country: 'Czechia', lat: 49.2, lon: 16.61, timeZone: 'Europe/Prague' }
};
const opened: Profile[] = [];
const opened: Storage[] = [];
/** A fresh, empty fake database per call unless one is passed: tests never share state. */
function open(indexedDB: IDBFactory = new IDBFactory()): Profile {
const p = openProfile({ indexedDB, IDBKeyRange });
function open(indexedDB: IDBFactory = new IDBFactory()): Storage {
const p = openStorage({ indexedDB, IDBKeyRange });
opened.push(p);
return p;
}
@@ -83,7 +83,7 @@ describe('the profile store — the sunset place', () => {
it('a database that cannot open rejects, so the app can fall back to the session', async () => {
const broken = new IDBFactory();
broken.open = () => { throw new DOMException('blocked by the browser', 'SecurityError'); };
await expect(openProfile({ indexedDB: broken, IDBKeyRange }).loadSunsetPlace()).rejects.toThrow();
await expect(openStorage({ indexedDB: broken, IDBKeyRange }).loadSunsetPlace()).rejects.toThrow();
});
});