DenReg/jsx-html/examples/03-async.tsx
Fabian Stamm 1b2d85eeef
All checks were successful
continuous-integration/drone/push Build is passing
Adding hotfixes for packages
2020-10-14 02:56:11 +02:00

31 lines
715 B
TypeScript

/// <reference path="../jsx.d.ts" />
import { assertEquals } from 'https://deno.land/std/testing/asserts.ts';
import { delay } from 'https://deno.land/std/async/delay.ts';
import { React } from '../mod.ts';
const Title = async () => {
await delay(100);
return <h1>title{ await delay(100) }</h1>;
};
const View = () => (
<div>
<Title />
</div>
);
if (import.meta.main) {
(<View />).render().then(console.log);
} else {
// Run test
Deno.test('render title', async () => {
assertEquals(await (<Title />).render(), '<h1>title</h1>');
});
Deno.test('render view', async () => {
assertEquals(await (<View />).render(), '<div><h1>title</h1></div>');
});
}