28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { analyseCopyPatterns } from '../src/content/heuristics';
|
|
import { evidenceFromHeuristics, heuristicScore } from '../src/background/heuristics';
|
|
|
|
describe('page heuristics', () => {
|
|
it('finds dense buzzwords and em-dash cadence without declaring an AI verdict', () => {
|
|
const text = 'Supercharge your workflow with our world-class, enterprise-grade platform — move faster — work smarter — without compromise.';
|
|
const findings = analyseCopyPatterns(text);
|
|
expect(findings.map((finding) => finding.ruleId)).toEqual(expect.arrayContaining([
|
|
'copy-marketing-buzzwords',
|
|
'copy-em-dash-cadence'
|
|
]));
|
|
expect(evidenceFromHeuristics(findings).every((item) => item.verdict === 'unknown')).toBe(true);
|
|
});
|
|
|
|
it('adds a diversity point when independent categories agree', () => {
|
|
const evidence = evidenceFromHeuristics([
|
|
{ ruleId: 'one', category: 'visual', title: 'One', detail: 'One', score: 2, occurrences: 1 },
|
|
{ ruleId: 'two', category: 'layout', title: 'Two', detail: 'Two', score: 3, occurrences: 1 }
|
|
]);
|
|
expect(heuristicScore(evidence)).toBe(6);
|
|
});
|
|
|
|
it('ignores ordinary direct prose', () => {
|
|
expect(analyseCopyPatterns('The archive contains monthly invoices. Select a year, then download the required PDF.')).toEqual([]);
|
|
});
|
|
});
|