import { lineKey, rupeesToMinor } from '../src/model'; describe('rupeesToMinor', () => { it.each([ ['₹99', 9900], ['₹1,234.50', 123450], ['₹1,23,456', 12345600], ['Rs. 12.5', 1250], [' INR 0 ', 0], ['45', 4500], ])('parses %s', (text, expected) => expect(rupeesToMinor(text)).toBe(expected)); it.each(['', 'free', '₹12.345', '₹-5', '₹5 + ₹3', '1e3', '₹1,2345'])('rejects %j', (text) => { expect(rupeesToMinor(text)).toBeNull(); }); }); describe('lineKey', () => { it('ignores case and repeated spaces but keeps store and size', () => { const base = { store: 'zepto' as const, sizeValue: 500, sizeUnit: 'g' as const }; expect(lineKey({ ...base, name: 'Amul Butter' })).toBe(lineKey({ ...base, name: 'amul butter' })); expect(lineKey({ ...base, name: 'Amul Butter' })).not.toBe(lineKey({ ...base, name: 'Amul Butter', sizeValue: 100 })); }); });