import { describe, expect, it } from 'vitest' import { html } from '../src/html.js' describe('html tagged template', () => { it('produces a {type, props, children} vnode', () => { const vnode = html`

hi

` expect(vnode).toMatchObject({ type: 'p', children: ['hi'] }) }) it('reads static attributes into props', () => { const vnode = html`y` expect(vnode.props).toEqual({ href: '/x' }) }) it('reads interpolated attribute values into props', () => { const href = '/dynamic' const vnode = html`y` expect(vnode.props.href).toBe('/dynamic') }) it('treats bare attributes as boolean true', () => { const vnode = html`` expect(vnode.type).toBe('input') expect(vnode.props).toEqual({ disabled: true }) }) it('supports spread props', () => { const vnode = html`y` expect(vnode.props).toMatchObject({ href: '/x', title: 't' }) }) it('nests child vnodes', () => { const vnode = html`` expect(vnode.type).toBe('ul') expect(vnode.children[0]).toMatchObject({ type: 'li', children: ['a'] }) }) it('interleaves text and interpolated values as children', () => { const vnode = html`

Hello ${'World'}

` expect(vnode.type).toBe('p') expect(vnode.children.join('')).toBe('Hello World') }) it('returns an array for multiple root nodes', () => { const vnodes = html`

a

b

` expect(Array.isArray(vnodes)).toBe(true) expect(vnodes).toHaveLength(2) }) })