import { describe, expect, it } from 'vitest'; import { h } from './h'; describe('h', () => { it('omits children entirely when there are none', () => { expect(h('div', { style: {} })).toEqual({ type: 'div', props: { style: {} } }); }); it('accepts null props', () => { expect(h('div', null, 'text')).toEqual({ type: 'div', props: { children: 'text' } }); }); it('unwraps a single child', () => { expect(h('div', null, 'only').props.children).toBe('only'); }); it('keeps several children as a list', () => { expect(h('div', null, 'a', 'b').props.children).toEqual(['a', 'b']); }); it('flattens nested arrays and drops empty branches', () => { // `condition && node` and `condition ? node : null` are the two shapes the // renderer uses to leave a block out; neither may reach satori. expect(h('div', null, ['a', ['b', null]], false, null, 'c').props.children).toEqual([ 'a', 'b', 'c', ]); }); it('keeps a zero, which is a legitimate child', () => { expect(h('div', null, 0).props.children).toBe(0); }); });