import { Hono } from '../../hono.ts' import { jsx, memo, Fragment } from './index.ts' describe('JSX middleware', () => { const app = new Hono() it('Should render HTML strings', async () => { app.get('/', (c) => { return c.html(
{[[['a']], [['b']]].map((item1) => item1.map((item2) => item2.map((item3) => {item3})) )}
) expect(template.toString()).toBe('ab
') }) it('Empty elements are rended withtout closing tag', () => { const template = () expect(template.toString()).toBe('') }) it('Props value is null', () => { const template = Hello expect(template.toString()).toBe('Hello') }) it('Props value is undefined', () => { const template = Hello expect(template.toString()).toBe('Hello') }) describe('dangerouslySetInnerHTML', () => { it('Should render dangerouslySetInnerHTML', () => { const template = expect(template.toString()).toBe('" is allowed here') }) it('Should get an error if both dangerouslySetInnerHTML and children are specified', () => { expect(() => ( Hello )).toThrow() }) }) // https://en.reactjs.org/docs/jsx-in-depth.html#booleans-null-and-undefined-are-ignored describe('Booleans, Null, and Undefined Are Ignored', () => { it.each([true, false, undefined, null])('%s', (item) => { expect(({item}).toString()).toBe('') }) it('falsy value', () => { const template = {0} expect(template.toString()).toBe('0') }) }) // https://en.reactjs.org/docs/jsx-in-depth.html#props-default-to-true describe('Props Default to “True”', () => { it('default prop value', () => { const template = Hello expect(template.toString()).toBe('Hello') }) }) // https://en.reactjs.org/docs/jsx-in-depth.html#functions-as-children describe('Functions as Children', () => { it('Function', () => { function Repeat(props: any) { const items = [] for (let i = 0; i < props.numTimes; i++) { items.push((props.children as Function)(i)) } return) expect(template.toString()).toBe( '