import { isStaticMarkup, STANDARD_HTML_TAGS } from '../src/engine/AreHTML.constants'; /** * Unit coverage for the static-island detector that drives the * tokenizer fast-path (skip per-node explosion) and the AddStaticHTML * one-shot materialisation. Correctness here is what guarantees we never * collapse a subtree that actually needs reactive per-node handling. */ describe('isStaticMarkup — static-island detection', () => { describe('returns TRUE for fully static content', () => { it('plain text', () => { expect(isStaticMarkup('Hello World')).toBe(true); }); it('text with HTML entities (the   case)', () => { expect(isStaticMarkup('Hello World')).toBe(true); expect(isStaticMarkup('a & b   c A')).toBe(true); }); it('a single standard element with static attributes', () => { expect(isStaticMarkup('hi')).toBe(true); }); it('nested standard elements', () => { expect(isStaticMarkup('
Hello World
')).toBe(true); }); it('static attribute value containing a colon (url / style)', () => { expect(isStaticMarkup('x')).toBe(true); expect(isStaticMarkup('x')).toBe(true); }); it('static attribute value containing @ (email)', () => { expect(isStaticMarkup('x')).toBe(true); }); it('void elements and self-closing tags', () => { expect(isStaticMarkup('line
break
')).toBe(true); expect(isStaticMarkup('pic')).toBe(true); }); it('table fragments', () => { expect(isStaticMarkup('ab')).toBe(true); }); it('html comments are inert', () => { expect(isStaticMarkup('xy')).toBe(true); }); it('single-quoted static attributes', () => { expect(isStaticMarkup("
x
")).toBe(true); }); }); describe('returns FALSE for dynamic content', () => { it('interpolations', () => { expect(isStaticMarkup('{{name}}')).toBe(false); expect(isStaticMarkup('Hello {{name}}')).toBe(false); }); it('binding attribute (:)', () => { expect(isStaticMarkup('
y
')).toBe(false); }); it('event attribute (@)', () => { expect(isStaticMarkup('')).toBe(false); }); it('directive attribute ($)', () => { expect(isStaticMarkup('
y
')).toBe(false); expect(isStaticMarkup('
  • y
  • ')).toBe(false); }); it('dynamic attribute nested deep in an otherwise static tree', () => { expect(isStaticMarkup('
    x
    ')).toBe(false); }); }); describe('returns FALSE for non-standard tags (components / custom / svg)', () => { it('custom component (kebab-case)', () => { expect(isStaticMarkup('')).toBe(false); expect(isStaticMarkup('
    x
    ')).toBe(false); }); it('are-root outlet', () => { expect(isStaticMarkup('')).toBe(false); }); it('svg elements (need namespace handling)', () => { expect(isStaticMarkup('')).toBe(false); expect(isStaticMarkup('
    ')).toBe(false); }); }); describe('edge cases', () => { it('empty / falsy content is not an island', () => { expect(isStaticMarkup('')).toBe(false); }); it('unterminated tag bails to the safe path', () => { expect(isStaticMarkup('
    { expect(isStaticMarkup(' ')).toBe(true); }); it('STANDARD_HTML_TAGS excludes svg/component tags', () => { expect(STANDARD_HTML_TAGS.has('div')).toBe(true); expect(STANDARD_HTML_TAGS.has('svg')).toBe(false); expect(STANDARD_HTML_TAGS.has('rect')).toBe(false); }); }); });