import { describe, expect, it } from 'vitest'; import { VaultRegistry, type MountedVault, type RemoteVault } from './registry'; import type { HabitatUri } from './types'; const remote = (id: string): RemoteVault => ({ state: 'remote-unsynced', name: id, did: 'did:plc:me', rootUri: `at://did:plc:me/network.habitat.vault.root/${id}` as HabitatUri, }); const syncedMount = (rootUri: HabitatUri): MountedVault => ({ state: 'synced', id: rootUri, name: 'v', path: '/tmp/v', did: 'did:plc:me', rootUri, }); const localMount = (): MountedVault => ({ state: 'local', id: 'local', name: 'v', path: '/tmp/v', }); describe('VaultRegistry.unsynced', () => { it('keeps remote roots that are not mounted', () => { const roots = [remote('a'), remote('b')]; expect(VaultRegistry.unsynced(roots, [])).toEqual(roots); }); it('filters out roots already synced (matched by rootUri)', () => { const a = remote('a'); const b = remote('b'); expect(VaultRegistry.unsynced([a, b], [syncedMount(a.rootUri)])).toEqual([ b, ]); }); it('ignores local mounts when filtering', () => { const a = remote('a'); expect(VaultRegistry.unsynced([a], [localMount()])).toEqual([a]); }); });