// Server renderer behavior, matching nanohtml 1.x server semantics. import { test } from 'node:test' import assert from 'node:assert' import html from '@choojs/html' import raw from '@choojs/html/raw' test('renders a template to a string', () => { const res = html`

hello

` assert.strictEqual(res.toString(), '

hello

') }) test('escapes interpolated text', () => { const res = html`

${''}

` assert.strictEqual(res.toString(), '

<script>alert(1)</script>

') }) test('raw() bypasses escaping', () => { const res = html`

${raw('hi')}

` assert.strictEqual(res.toString(), '

hi

') }) test('nested templates are not double-encoded', () => { const inner = html`&` const res = html`

${inner}

` assert.strictEqual(res.toString(), '

&

') }) test('arrays of children are joined', () => { const items = ['a', 'b'].map((x) => html`
  • ${x}
  • `) const res = html`` assert.strictEqual(res.toString(), '') }) test('unquoted attribute interpolation is quoted', () => { const res = html`
    ` assert.strictEqual(res.toString(), '
    ') }) test('boolean attributes render when truthy and drop when falsy', () => { const on = html`` const off = html`` assert.strictEqual(on.toString(), '') assert.strictEqual(off.toString(), ''.replace(' ', ' ')) }) test('event handler functions leave no trace in markup', () => { const res = html`` assert.strictEqual(res.toString(), '') }) test('handler-shaped attributes with non-function values still render', () => { const res = html`x` assert.strictEqual(res.toString(), 'x') }) test('spread-style object interpolation renders attributes', () => { const res = html`
    ` assert.strictEqual(res.toString(), '') })