import { test, expect } from 'vitest'; import { markUnits, unitNote } from './biblicalUnits.js'; const noted = (text) => markUnits(text).filter((p) => p.note).map((p) => p.text); test('units in a verse are found with their meaning, in any form', () => { expect(noted('The ark was two and a half cubits long and a handbreadth thick.')).toEqual(['cubits', 'handbreadth']); expect(noted('He gave him five talents, and she lost one drachma; it cost a denarius.')).toEqual(['talents', 'drachma', 'denarius']); expect(noted('An ephah of flour, an omer of manna, and a hin of oil.')).toEqual(['ephah', 'omer', 'hin']); expect(noted('about twenty-five or thirty stadia')).toEqual(['stadia']); expect(unitNote('Talent')).toMatch(/75 pounds/); }); test('the pieces rejoin to the original text, and a verse with no units is one piece', () => { const text = 'five talents of silver (a talent is heavy)'; expect(markUnits(text).map((p) => p.text).join('')).toBe(text); expect(markUnits('For God so loved the world')).toEqual([{ text: 'For God so loved the world' }]); expect(markUnits('')).toEqual([{ text: '' }]); }); test('ordinary words are not mistaken for units', () => { expect(noted('He took a pound of flesh; a span of the river; the mile stone')).toEqual(['span', 'mile']); expect(noted('Bathsheba and Cornelius, the stadium crowd, a corner and a hinge')).toEqual([]); }); test('a mina is a mina, and the older word pound is left alone', () => { expect(noted('ten minas and a mina')).toEqual(['minas', 'mina']); expect(unitNote('pound')).toBeNull(); });