Files
2026-09-14 22:38:47 -04:00

24 lines
1013 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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]), []);
});