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 =
'
');
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([]);
});
});