import { test, expect } from 'vitest'; import { parseChapterText, parseEsvReference } from './bibleApi.js'; test('parseChapterText splits inline verse markers and cleans provider artifacts', () => { const text = ' [1] The Lord is my shepherd;\n I have what I need.\n [2] He lets me lie down #— in pastures, ,\n'; expect(parseChapterText(text)).toEqual([ { number: 1, text: 'The Lord is my shepherd; I have what I need.' }, { number: 2, text: 'He lets me lie down — in pastures,' }, ]); }); test('parseChapterText ignores headings before the first verse', () => { expect(parseChapterText('Psalm 23\n\nA Psalm of David.\n\n[1] The LORD is my shepherd;')).toEqual([ { number: 1, text: 'The LORD is my shepherd;' }, ]); }); test('parseEsvReference maps ESV book names back to abbreviations', () => { expect(parseEsvReference('Psalm 23:1')).toEqual({ bookAbbrev: 'PSA', chapter: 23, verse: 1 }); expect(parseEsvReference('1 John 3:16-18')).toEqual({ bookAbbrev: '1JN', chapter: 3, verse: 16 }); expect(parseEsvReference('Song of Solomon 2:4')).toEqual({ bookAbbrev: 'SNG', chapter: 2, verse: 4 }); expect(parseEsvReference('Not a book 1:1')).toBeNull(); });