import { describe, it, expect } from 'vitest'; import { normalizeHtml } from './normalize.ts'; import { diffStruct } from './diff.ts'; describe('structural diff', () => { it('ignores class/style/whitespace changes (the de-Tailwind case)', () => { const live = `
Hi
`; const next = `
Hi
`; expect(diffStruct(normalizeHtml(live), normalizeHtml(next))).toEqual([]); }); it('flags a changed href (real content/structure change)', () => { const live = `Hi`; const next = `Hi`; const d = diffStruct(normalizeHtml(live), normalizeHtml(next)); expect(d).toHaveLength(1); expect(d[0].kind).toBe('attr'); }); it('flags changed text and missing nodes', () => { const live = ``; const next = ``; const d = diffStruct(normalizeHtml(live), normalizeHtml(next)); expect(d.some((x) => x.kind === 'missing')).toBe(true); }); it('treats svg as an opaque leaf (icon internals are noise)', () => { const live = ``; const next = ``; // same svg attrs, different internal path data → children dropped → no divergence expect(diffStruct(normalizeHtml(live), normalizeHtml(next))).toEqual([]); }); });