Files
study-bible-project/server/bibleApi.test.js
nmemmertandClaude Sonnet 5.5 c11b6a60bf
Build and Push Docker Image / build-and-push (push) Failing after 20s
Reader: whole-Bible search in every translation
BSB and NET are indexed in the browser; ESV, NLT, CSB and NASB are searched
through a server proxy (keys stay server-side). Results page in 25 at a time
and jump to the verse. Also fixes a stray trailing comma in CSB chapter text.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-09-29 09:25:00 -04:00

24 lines
1.2 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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();
});