import { describe, expect, it } from 'vitest'; import { resolveDataRef, resolveDataRefBoolean, resolveDataRefString } from './resolve-data-ref'; describe('resolveDataRef', () => { const data = { user: { name: 'Ada', flags: { admin: true } } }; it('walks dotted paths', () => { expect(resolveDataRef(data, 'user.name')).toBe('Ada'); expect(resolveDataRef(data, 'missing.path')).toBeUndefined(); expect(resolveDataRef(data, undefined)).toBeUndefined(); }); it('coerces string and boolean refs', () => { expect(resolveDataRefString(data, 'user.name')).toBe('Ada'); expect(resolveDataRefString(data, 'missing')).toBe(''); expect(resolveDataRefBoolean(data, 'user.flags.admin')).toBe(true); expect(resolveDataRefBoolean(data, 'user.name')).toBe(false); }); });