import { describe, it, expect } from 'vitest' import { nameResolver } from './parentNames' import type { PersonalData } from '@/types' const member = (overrides: Partial = {}): PersonalData => ({ uuid: 'pd-1', workspaceId: 'ws-1', name: 'Alex', salaryType: 'monthly', employmentStatus: 'employed', createdAt: '2026-01-01', ...overrides, }) describe('nameResolver', () => { it('resolves a uuid to the matching member name', () => { const nameFor = nameResolver([member(), member({ uuid: 'pd-2', name: 'Sam' })]) expect(nameFor('pd-1')).toBe('Alex') expect(nameFor('pd-2')).toBe('Sam') }) it('falls back to the uuid itself when no member matches', () => { const nameFor = nameResolver([member()]) expect(nameFor('unknown-uuid')).toBe('unknown-uuid') }) it('falls back to the uuid for an empty members list', () => { const nameFor = nameResolver([]) expect(nameFor('pd-1')).toBe('pd-1') }) })