import { describe, test, expect } from 'vitest'; import { storageKey, extractPartOfSpeech, htmlToPlainText, renderVerseContent, parseBibleChapter, wordTableHtml, buildExportHtml, buildMarkdownExport, buildClaudePrompt, createParagraphsFromText, migrateChunk, migrateProject, } from './App.jsx'; // --------------------------------------------------------------------------- // storageKey // --------------------------------------------------------------------------- describe('storageKey', () => { test('formats key with translation, book, and chapter', () => { expect(storageKey('BSB', 'TIT', '1')).toBe('bible-study-BSB-TIT-1'); }); test('handles different values', () => { expect(storageKey('KJV', 'MAT', '5')).toBe('bible-study-KJV-MAT-5'); }); }); // --------------------------------------------------------------------------- // extractPartOfSpeech // --------------------------------------------------------------------------- describe('extractPartOfSpeech', () => { test('extracts single-word part of speech', () => { expect(extractPartOfSpeech('

Part(s) of speech: Noun

')).toBe('Noun'); }); test('extracts multi-word part of speech', () => { expect(extractPartOfSpeech('

Part(s) of speech: Verb, Intransitive

')).toBe('Verb, Intransitive'); }); test('is case-insensitive on the label', () => { expect(extractPartOfSpeech('

PART(S) OF SPEECH: Adjective

')).toBe('Adjective'); }); test('returns empty string when label is absent', () => { expect(extractPartOfSpeech('

Some other text

')).toBe(''); }); test('returns empty string for empty input', () => { expect(extractPartOfSpeech('')).toBe(''); }); test('returns empty string for null', () => { expect(extractPartOfSpeech(null)).toBe(''); }); test('returns empty string for undefined', () => { expect(extractPartOfSpeech(undefined)).toBe(''); }); }); // --------------------------------------------------------------------------- // htmlToPlainText // --------------------------------------------------------------------------- describe('htmlToPlainText', () => { test('extracts text from a paragraph', () => { expect(htmlToPlainText('

Hello world

')).toBe('Hello world'); }); test('returns empty string for empty input', () => { expect(htmlToPlainText('')).toBe(''); }); test('strips script tags leaving safe text intact (XSS regression)', () => { const result = htmlToPlainText('Safe text'); expect(result).not.toContain('