[storage] CareLog: Append-only care events and the kept identity, checked against the contract
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user