Files
study-bible-project/src/utils/seriesProgress.test.js
T
nmemmertandClaude Sonnet 5.5 a6af9bd1c6
Build and Push Docker Image / build-and-push (push) Successful in 6m41s
Teaching tools: word occurrences, blanks handout, templates, series progress, book info, comments
- Words tab: "Where else" lists every verse using a Strong's number, by book
  (new /api/strongs/:number/occurrences, indexed from the interlinear files)
- Handout: fill-in-the-blanks layout with a word bank
- Four new study templates: character, topical, word, verse by verse
- Finish: series progress (not started / studied / ready / taught)
- Background: book at a glance for all 66 books
- Chunk comments for co-teachers, merged between copies
- TODO: correct BSB audio note, tick co-teacher comments

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-27 15:44:37 -04:00

39 lines
1.8 KiB
JavaScript

import { test, expect } from 'vitest';
import { seriesProgress, stageOf } from './seriesProgress.js';
const chunk = (id, x = {}) => ({ id, startVerse: 1, endVerse: 2, ...x });
const project = (chunks, outline = []) => ({ title: 'Romans', outline, chapters: [{ book: 'Romans', bookAbbrev: 'ROM', chapter: '8', verses: [], chunks }] });
test('a session moves from not started to taught as things get written', () => {
const p = project([chunk('a')]);
expect(stageOf(p, chunk('a'))).toBe(0);
expect(stageOf(p, chunk('a', { observation: 'Notes' }))).toBe(1);
expect(stageOf(p, chunk('a', { observation: 'Notes', discussionQuestions: 'Why?' }))).toBe(2);
expect(stageOf(p, chunk('a', { observation: 'Notes', groupNotes: 'They liked it' }))).toBe(3);
expect(stageOf(p, chunk('a', { attendees: ' ' }))).toBe(0);
});
test('an outline point linked to the session counts as ready to teach', () => {
const p = project([chunk('a', { application: 'x' })], [{ id: 'o', text: 'Point', chunkId: 'a', children: [] }]);
expect(stageOf(p, p.chapters[0].chunks[0])).toBe(2);
});
test('the series summary counts stages, open follow-ups and comments, and names the next session to teach', () => {
const p = project([
chunk('a', { groupNotes: 'Done', followUps: [{ id: 'f1', text: 'x', done: false }, { id: 'f2', text: 'y', done: true }] }),
chunk('b', { observation: 'Started', comments: [{ id: 'c1', done: false }, { id: 'c2', done: true }] }),
chunk('c'),
]);
const s = seriesProgress(p);
expect(s.counts).toEqual([1, 1, 0, 1]);
expect(s.taught).toBe(1);
expect(s.total).toBe(3);
expect(s.rows[0].openFollowUps).toBe(1);
expect(s.rows[1].openComments).toBe(1);
expect(s.next.id).toBe('b');
});
test('a finished series has no next session', () => {
expect(seriesProgress(project([chunk('a', { teachBack: 'x' })])).next).toBeNull();
});