import { resolvePlacementValue, toPlacementFormState, withPlacementCustomFallback } from './items'; describe('items helpers', () => { test('toPlacementFormState keeps known placements as-is', () => { expect(toPlacementFormState('suitcase')).toEqual({ placement: 'suitcase', placementCustom: '', }); }); test('toPlacementFormState converts custom placements to other with value', () => { expect(toPlacementFormState('hotel safe')).toEqual({ placement: 'other', placementCustom: 'hotel safe', }); }); test('resolvePlacementValue returns custom value when placement is other', () => { expect(resolvePlacementValue('other', ' hotel safe ')).toBe('hotel safe'); }); test('resolvePlacementValue returns direct placement when not other', () => { expect(resolvePlacementValue('backpack', 'ignored')).toBe('backpack'); }); test('withPlacementCustomFallback prefers existing custom value', () => { expect(withPlacementCustomFallback('closet shelf', 'hotel safe')).toBe('closet shelf'); }); test('withPlacementCustomFallback uses fallback when custom is empty', () => { expect(withPlacementCustomFallback(' ', 'hotel safe')).toBe('hotel safe'); }); });