import test from 'node:test'; import assert from 'node:assert/strict'; import { filterUnits, subjectsFor, teacherGuidesFor } from '../src/library.mjs'; const units = [ { subject: 'Math', title: 'Grade 3 Math', materials: [{ role: 'Teacher Guide', id: 'math-guide' }] }, { subject: 'Science', title: 'Grade 3 Science', materials: [{ role: 'Student Reader', id: 'science-reader' }] }, { subject: 'Math', title: 'Math Literature', materials: [] }, ]; test('lists available subjects with All first', () => { assert.deepEqual(subjectsFor(units), ['All', 'Math', 'Science']); }); test('filters units by selected subject', () => { assert.deepEqual(filterUnits(units, 'Math').map((unit) => unit.title), ['Grade 3 Math', 'Math Literature']); assert.equal(filterUnits(units, 'All').length, 3); }); test('selects only a unit’s teacher-plan PDFs', () => { assert.deepEqual(teacherGuidesFor(units[0]), [{ role: 'Teacher Guide', id: 'math-guide' }]); assert.deepEqual(teacherGuidesFor(units[1]), []); });