import { describe, it, expect } from 'vitest'; import { decodeHtmlEntities } from './utils'; describe('decodeHtmlEntities', () => { it('decodes < and > to < and >', () => { expect(decodeHtmlEntities('<b>bold</b>')).toBe('bold'); }); it('decodes & to &', () => { expect(decodeHtmlEntities('Tom & Jerry')).toBe('Tom & Jerry'); }); it('decodes " and ' to quote characters', () => { expect(decodeHtmlEntities('"hello" 'world'')).toBe(`"hello" 'world'`); }); it('decodes numeric entities', () => { expect(decodeHtmlEntities('<div>')).toBe('
'); }); it('decodes hex entities', () => { expect(decodeHtmlEntities('<span>')).toBe(''); }); it('returns plain text unchanged', () => { expect(decodeHtmlEntities('no entities here')).toBe('no entities here'); }); it('handles mixed encoded and plain text', () => { expect(decodeHtmlEntities('BP < 120 & HR > 60')).toBe('BP < 120 & HR > 60'); }); it('returns an empty string for empty input', () => { expect(decodeHtmlEntities('')).toBe(''); }); });