import { nextPriceSource, isUnconfirmed } from '../../src/intake/priceSource'; describe('nextPriceSource', () => { // Touching the number is the admin taking responsibility for it. That is the // only event that can confirm a price. it('becomes admin when the number changes', () => { expect(nextPriceSource('default', 9500, 8000)).toBe('admin'); expect(nextPriceSource('ai', 4000, 4500)).toBe('admin'); }); // Publishing without touching the field must NOT silently confirm it. That // is the whole failure this screen exists to prevent: an item selling at a // number nobody chose, with nothing recording that. it('leaves an untouched price unconfirmed', () => { expect(nextPriceSource('default', 8000, 8000)).toBe('default'); expect(nextPriceSource('ai', 4500, 4500)).toBe('ai'); }); // Already confirmed stays confirmed, including when re-submitted unchanged. it('keeps admin once set', () => { expect(nextPriceSource('admin', 9500, 9500)).toBe('admin'); expect(nextPriceSource('admin', 7000, 9500)).toBe('admin'); }); }); describe('isUnconfirmed', () => { it('treats anything but admin as unconfirmed', () => { expect(isUnconfirmed('default')).toBe(true); expect(isUnconfirmed('ai')).toBe(true); expect(isUnconfirmed('admin')).toBe(false); }); });