import { describe, expect, it } from 'vitest'; import { firstDifferences, normalizeHtml } from './htmlBaseline.ts'; describe('normalizeHtml', () => { it('keeps text, links, labels, meta and structured data', () => { const html = 'Titel' + '' + 'Over mij' + ''; const out = normalizeHtml(html); for (const part of [ 'Titel', 'content="Tekst"', 'rel="canonical"', 'aria-label="Naar over mij"', 'Over mij', '{"a":1}', ]) { expect(out).toContain(part); } }); it('leaves out look and build details', () => { const html = '' + '' + '
tekst
' + ''; const out = normalizeHtml(html); expect(out).not.toMatch( /css-1abc|color:red|data-reveal|opmerking|\.a\{|stylesheet|AbCd1234.js/, ); expect(out).toContain('
'); expect(out).toContain('/assets/foto.jpg'); expect(out).toContain( '', ); }); it('keeps the CMS markers and the data block', () => { const html = '' + 'a'; const out = normalizeHtml(html); expect(out).toContain(''); expect(out).toContain('{"x":1}'); expect(out).toContain(''); }); it('notices a changed word', () => { expect(normalizeHtml('

een

')).not.toBe( normalizeHtml('

twee

'), ); }); it('puts one tag per line and ends with a newline', () => { expect(normalizeHtml('')).toBe( '\n', ); }); }); describe('firstDifferences', () => { it('shows the lines that differ, at most a few', () => { const out = firstDifferences('a\nb\nc', 'a\nB\nc\nd'); expect(out.join('\n')).toContain('regel 2'); expect(out.join('\n')).toContain('basislijn: b'); expect(out.join('\n')).toContain('nu: B'); expect(out.join('\n')).toContain('(geen)'); expect(firstDifferences('a', 'a')).toEqual([]); }); });