"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const recipe_parser_1 = require("./recipe-parser"); describe('parseRecipeMarkdown — ingrediensformat', () => { const parse = (line) => { const md = `# Test\n## Ingredienser\n- ${line}\n## Instruktioner\n1. Gör det.`; return (0, recipe_parser_1.parseRecipeMarkdown)(md).ingredients[0]; }; it('vanlig rad: kvantitet enhet namn', () => { const ing = parse('400 g kycklingfilé'); expect(ing).toMatchObject({ quantity: 400, unit: 'g', rawName: 'kycklingfilé' }); }); it('bråk: 1 1/2 dl grädde', () => { const ing = parse('1 1/2 dl grädde'); expect(ing.quantity).toBeCloseTo(1.5); expect(ing).toMatchObject({ unit: 'dl', rawName: 'grädde' }); }); it('bråk utan heltal: 1/2 dl mjölk', () => { const ing = parse('1/2 dl mjölk'); expect(ing.quantity).toBeCloseTo(0.5); expect(ing).toMatchObject({ unit: 'dl', rawName: 'mjölk' }); }); it('intervall: 600 - ca 700 g kycklingfilé', () => { const ing = parse('600 - ca 700 g kycklingfilé'); expect(ing.quantity).toBeCloseTo(650); expect(ing).toMatchObject({ unit: 'g', rawName: 'kycklingfilé' }); }); it('intervall: ca 600-700 g kycklingfilé', () => { const ing = parse('ca 600-700 g kycklingfilé'); expect(ing.quantity).toBeCloseTo(650); expect(ing).toMatchObject({ unit: 'g' }); }); it('intervall med alternativt namn: 600 - ca 700 g kycklingfilé eller kycklinginnerfilé', () => { const ing = parse('600 - ca 700 g kycklingfilé eller kycklinginnerfilé'); expect(ing.quantity).toBeCloseTo(650); expect(ing).toMatchObject({ unit: 'g', rawName: 'kycklingfilé eller kycklinginnerfilé' }); }); it('parentes-not: 2 dl grädde (eller crème fraiche)', () => { const ing = parse('2 dl grädde (eller crème fraiche)'); expect(ing).toMatchObject({ quantity: 2, unit: 'dl', rawName: 'grädde', note: 'eller crème fraiche' }); }); it('utan enhet: 3 ägg', () => { const ing = parse('3 ägg'); expect(ing).toMatchObject({ quantity: 3, unit: 'st', rawName: 'ägg' }); }); it('bara namn: salt', () => { const ing = parse('salt'); expect(ing).toMatchObject({ quantity: 0, unit: '', rawName: 'salt' }); }); it('decimalkomma: 2,5 dl mjölk', () => { const ing = parse('2,5 dl mjölk'); expect(ing.quantity).toBeCloseTo(2.5); expect(ing).toMatchObject({ unit: 'dl', rawName: 'mjölk' }); }); }); //# sourceMappingURL=recipe-parser.spec.js.map