cleaner test API

Summary: The test mock utilities now return a promise, rather than taking a callback, which makes tests slightly nicer to read (similar to react-testing-library). No semantic changes.

Reviewed By: jknoxville

Differential Revision: D22186278

fbshipit-source-id: ec5b9f4e6bfeee9160e331f8c20a1d4fdcbfeede
This commit is contained in:
Michel Weststrate
2020-07-01 08:58:40 -07:00
committed by Facebook GitHub Bot
parent 12ac29685d
commit 83e6968fa1
4 changed files with 317 additions and 339 deletions

View File

@@ -46,10 +46,10 @@ class TestPlugin extends FlipperPlugin<any, any, any> {
}
test('Plugin container can render plugin and receive updates', async () => {
await renderMockFlipperWithPlugin(
const {renderer, sendMessage, act} = await renderMockFlipperWithPlugin(
TestPlugin,
async ({renderer, sendMessage, act}) => {
expect(renderer.baseElement).toMatchInlineSnapshot(`
);
expect(renderer.baseElement).toMatchInlineSnapshot(`
<body>
<div>
<div
@@ -73,11 +73,9 @@ test('Plugin container can render plugin and receive updates', async () => {
</body>
`);
act(() => {
sendMessage('inc', {delta: 2});
});
act(() => {
sendMessage('inc', {delta: 2});
});
expect((await renderer.findByTestId('counter')).textContent).toBe('2');
},
);
expect((await renderer.findByTestId('counter')).textContent).toBe('2');
});