import { describe, expect, it } from 'vitest'; import { FORBIDDEN, findForbidden } from '../src/forbidden.js'; const terms = (text: string): string[] => findForbidden(text).map((h) => h.term); describe('forbidden words — what is caught', () => { it('catches every listed term on its own', () => { const missed = FORBIDDEN.filter(({ term }) => !terms(`before ${term} after`).includes(term)).map((t) => t.term); expect(missed).toEqual([]); }); it.each([ ['A soft THERAPY for the soul', 'therapy'], ['self-healing petals', 'healing'], ["the rose's lonely planet", 'lonely'], ['Loneliness.', 'loneliness'], ['a treat for the fox', 'treat'], ['be patient with yourself', 'patient'], ['Middle-earth', 'Middle-earth'], ['Middle earth', 'Middle-earth'], ['Malý princ', 'Malý princ'], ['Saint-Exupéry wrote', 'Saint-Exupéry'] ])('"%s" contains %s', (text, term) => { expect(terms(text)).toContain(term); }); it('reports hits in reading order', () => { expect(terms('cure first, then therapy')).toEqual(['cure', 'therapy']); }); }); describe('forbidden words — what is NOT caught', () => { it.each([ 'a treaty between two roses', 'a healthy rose', 'patience, and patiently waiting', 'the lamplighter on his planet', 'the king, the vain man, the businessman', 'a fox among the berries', 'Rosea Domi' ])('"%s" is clean', (text) => { expect(terms(text)).toEqual([]); }); });