import { describe, expect, it } from 'vitest';
import { stripHtml } from './text.js';
describe('zhihu text helpers', () => {
it('strips tags and decodes named entities in flat mode', () => {
expect(stripHtml('Codex & <CLI>')).toBe('Codex & ');
});
it('decodes decimal and hexadecimal numeric entities', () => {
expect(stripHtml('"中文" & 'test'')).toBe('"中文" & \'test\'');
});
it('keeps invalid numeric entities unchanged', () => {
expect(stripHtml('bad entity')).toBe('bad entity');
});
it('keeps list excerpts flat by default', () => {
expect(stripHtml('first
second
')).toBe('firstsecond');
});
it('preserves block breaks when requested', () => {
expect(stripHtml('first
second
', { preserveBlocks: true })).toBe('first\n\nsecond');
});
});