diff --git a/scripts/smoke.mjs b/scripts/smoke.mjs index 02f90be..70f83cc 100644 --- a/scripts/smoke.mjs +++ b/scripts/smoke.mjs @@ -11,7 +11,7 @@ import { resolve, dirname } from 'node:path'; import { fileURLToPath } from 'node:url'; import { Personalizer, collectThemes, normalizeTheme } from '../src/personalize.js'; import { SearchIndex, tokenize, snippet } from '../src/search.js'; -import { asMovements, monthByNumber, movementOf, mirrorOf, currentMonth, neighbors } from '../src/journey.js'; +import { asMovements, monthByNumber, monthsOfMovement, movementOf, mirrorOf, currentMonth, neighbors } from '../src/journey.js'; const root = resolve(dirname(fileURLToPath(import.meta.url)), '..'); const { articles } = JSON.parse( @@ -57,6 +57,14 @@ check('collectThemes returns a sorted, de-duplicated set', () => { assert.deepEqual(themes, [...new Set(themes)].sort()); }); +check('collectThemes deduplicates themes that differ only by case', () => { + const themes = collectThemes([ + { themes: ['Vedanta', 'Sadhana'] }, + { themes: ['vedanta'] }, // normalises to the same key as 'Vedanta' + ]); + assert.deepEqual(themes, ['sadhana', 'vedanta']); // 2 items, not 3 +}); + console.log('search.js'); check('finds a distinctive term in the right article', () => { @@ -111,6 +119,12 @@ check('neighbors are the adjacent months, with no wraparound', () => { assert.equal(neighbors(arc, 12).next, null); }); +check('monthsOfMovement returns months in calendar order for a movement', () => { + const months = monthsOfMovement(arc, 'ground'); + assert.equal(months.length, 5); // January through May + assert.deepEqual(months.map((m) => m.number), [1, 2, 3, 4, 5]); +}); + console.log('personalize.js (more)'); check('reading an article adds the seen penalty and reason', () => { @@ -145,6 +159,11 @@ check('snippet falls back to the start of the text when nothing matches', () => assert.ok(s.startsWith('Gratitude')); }); +check('snippet with no terms falls back to the start of the text', () => { + const s = snippet({ summary: 'Aspiration is the flame lit on the ground of gratitude.' }); + assert.ok(s.startsWith('Aspiration')); +}); + check('search matches an author name', () => { const idx = new SearchIndex().build([ { title: 'On stillness', themes: ['Silence'], author: 'Nirodbaran', summary: 'x', body: 'y' },