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