import { test, expect } from 'vitest'; import { buildSlides, buildSlidesHtml } from './slides.js'; const project = () => ({ id: 'p', title: 'John ', translation: 'BSB', outline: [], chapters: [{ book: 'John', bookAbbrev: 'JHN', chapter: '3', verses: [{ number: 16, text: 'For God so loved the world.' }, { number: 17, text: 'God sent not his Son to condemn.' }], chunks: [ { id: 'a', startVerse: 16, endVerse: 17, episodeTitle: 'God so loved', discussionQuestions: 'Why did he give?\nWho is "the world"?', outline: [{ id: 'n1', text: 'Love gives', children: [{ id: 'n2', text: 'He gave', scripture: { text: 'For God so loved', ref: 'John 3:16' }, children: [] }] }] }, { id: 'b', startVerse: 17, endVerse: 17, application: 'Trust him.', outline: [] }, ] }], }); test('slides run title, then per session: section, passage, points, questions', () => { const kinds = buildSlides(project()).map((s) => s.kind); expect(kinds).toEqual(['title', 'section', 'passage', 'point', 'point', 'questions', 'section', 'passage', 'questions']); const slides = buildSlides(project()); expect(slides[1]).toMatchObject({ title: 'God so loved', subtitle: 'John 3:16–17' }); expect(slides[4]).toMatchObject({ depth: 1, text: 'He gave', quote: { ref: 'John 3:16' } }); expect(slides[8]).toMatchObject({ title: 'Think about it', items: ['Trust him.'] }); // Application notes stand in for questions }); test('one session only', () => { const kinds = buildSlides(project(), ['b']).map((s) => s.kind); expect(kinds).toEqual(['title', 'section', 'passage', 'questions']); }); test('the printable page has a 16:9 slide per entry, escapes text, and can be dark', () => { const html = buildSlidesHtml(project()); expect(html.match(/class="slide/g)).toHaveLength(9); expect(html).toContain('John <study>'); expect(html).toContain('size: 13.333in 7.5in'); expect(html).not.toContain(''); expect(buildSlidesHtml(project(), null, { dark: true })).toContain('#16130f'); });