Skip to content

Commit 8eb9b8e

Browse files
add test for variables passing
1 parent 4f74fa9 commit 8eb9b8e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

tests/Coroutine.test.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@ import Coroutine from '../src/Coroutine';
44

55
describe('Coroutine', async () => {
66
it('should render empty body until coroutine is resolved', async () => {
7-
const TestComponent = Coroutine.create(async () => <p>test</p>);
7+
const render = async () => <p>test</p>;
8+
const TestComponent = Coroutine.create(render);
89
const tree = Renderer.create(<TestComponent />);
9-
const initial = Renderer.create(<noscript />);
10-
const success = Renderer.create(<p>test</p>);
1110

11+
const initial = Renderer.create(<noscript />);
1212
expect(tree.toJSON()).toEqual(initial.toJSON());
13-
await true;
13+
14+
const success = await Renderer.create(<p>test</p>);
15+
expect(tree.toJSON()).toEqual(success.toJSON());
16+
});
17+
18+
it('should pass initial information', async () => {
19+
const render = async ({ number }) => <p>{ number }</p>;
20+
const variables = () => ({ number: 13 });
21+
const TestComponent = Coroutine.create(render, variables);
22+
const tree = Renderer.create(<TestComponent />);
23+
24+
const success = await Renderer.create(<p>{13}</p>);
1425
expect(tree.toJSON()).toEqual(success.toJSON());
1526
});
1627
});

0 commit comments

Comments
 (0)