import { describe, expect, it } from 'vitest' import { bodyCounts, isLargeBody, LARGE_BODY_CHARACTERS } from '../bodyCounts' describe('bodyCounts', () => { it('counts words across block boundaries and characters as the string length', () => { const html = '
A bold end.
' expect(bodyCounts(html)).toEqual({ words: 6, characters: html.length }) }) it('splits adjacent blocks and line breaks into separate words', () => { expect(bodyCounts('one
two
').words).toBe(2) expect(bodyCounts('one
two
one two
').words).toBe(2) }) it('counts no words in markup without text', () => { expect(bodyCounts('')).toEqual({ words: 0, characters: 8 }) }) it('reads an empty document as zero', () => { expect(bodyCounts('')).toEqual({ words: 0, characters: 0 }) expect(bodyCounts('')).toEqual({ words: 0, characters: 0 }) }) }) describe('isLargeBody', () => { it('flips exactly at the threshold', () => { expect(isLargeBody(LARGE_BODY_CHARACTERS - 1)).toBe(false) expect(isLargeBody(LARGE_BODY_CHARACTERS)).toBe(true) }) })