import { describe, expect, it } from 'vitest'; import { lintCopy, stripComments } from '../src/copy-lint.js'; describe('lint:copy core', () => { it('reports a forbidden word in a string, with its line', () => { const problems = lintCopy("export const a = 'ok';\nexport const b = 'A gentle therapy';\n"); expect(problems).toHaveLength(1); expect(problems[0]?.line).toBe(2); expect(problems[0]?.message).toContain('therapy'); }); it('reports a forbidden word in Svelte markup', () => { expect(lintCopy('
For the lonely.
')).toHaveLength(1); }); it('ignores comments, where rules are explained', () => { expect(lintCopy('// never say therapy\n/* nor lonely */\n\nconst ok = 1;')).toEqual([]); }); it('keeps line numbers when it strips a multi-line comment', () => { const problems = lintCopy("/*\n\n*/\nconst s = 'cure';"); expect(problems[0]?.line).toBe(4); }); it('does not mistake a URL for a comment', () => { expect(stripComments("'https://example.invalid/cure'")).toContain('cure'); }); it("reports 'Domi' standing alone", () => { expect(lintCopy("const title = 'Domi';")).toHaveLength(1); expect(lintCopy("const title = 'Welcome to Domi';")).toHaveLength(1); }); it("accepts 'Domi' after its first word", () => { expect(lintCopy("'Rosea Domi', 'Panda Domi', 'Amicitia Domi'")).toEqual([]); }); it('accepts clean shell copy', () => { expect(lintCopy("preparing: 'The garden is being prepared.'")).toEqual([]); }); });