a post-component library for building user-interfaces on the web.
at main 27 lines 726 B view raw
1import { html } from 'dhtml' 2import { assert_eq, test } from '../../../scripts/test/test.ts' 3import { renderToString } from '../../server.ts' 4 5const DEPTH = 10 6 7test('basic recursion is handled correctly', () => { 8 const app = { 9 renders: 0, 10 render() { 11 if (++this.renders > DEPTH) return 'hello!' 12 return this 13 }, 14 } 15 assert_eq(renderToString(app), '<?[>'.repeat(DEPTH) + '<?[>hello!<?]>' + '<?]>'.repeat(DEPTH)) 16}) 17 18test('nested recursion is handled correctly', () => { 19 const app = { 20 renders: 0, 21 render() { 22 if (++this.renders > DEPTH) return 'hello!' 23 return html`<span>${this}</span>` 24 }, 25 } 26 assert_eq(renderToString(app), '<?[><span>'.repeat(DEPTH) + '<?[>hello!<?]>' + '</span><?]>'.repeat(DEPTH)) 27})