import { describe, expect, it, vi } from 'vitest' import { createElement } from '../../src/utils/create-element.mjs' import { html } from '../../src/html.js' describe('createElement', () => { it('turns a string leaf into a text node', () => { const node = createElement('hello') expect(node.nodeType).toBe(Node.TEXT_NODE) expect(node.textContent).toBe('hello') }) it('builds an element from a vnode', () => { const el = createElement({ type: 'p', props: null, children: ['hi'] }) expect(el.tagName).toBe('P') expect(el.textContent).toBe('hi') }) it('assigns known DOM properties directly', () => { const el = createElement({ type: 'div', props: { id: 'foo' }, children: [] }) expect(el.id).toBe('foo') }) it('falls back to setAttribute for unknown props', () => { const el = createElement({ type: 'div', props: { 'data-x': 'y' }, children: [] }) expect(el.getAttribute('data-x')).toBe('y') }) it('applies style objects', () => { const el = createElement(html`
a
b
`) expect(frag.querySelectorAll('p')).toHaveLength(2) }) })