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:
committed by
Facebook GitHub Bot
parent
12ac29685d
commit
83e6968fa1
@@ -40,24 +40,25 @@ class TestPlugin extends FlipperPlugin<any, any, any> {
|
||||
}
|
||||
|
||||
test('can create a Fake flipper', async () => {
|
||||
await createMockFlipperWithPlugin(
|
||||
TestPlugin,
|
||||
async ({client, device, store, sendMessage}) => {
|
||||
expect(client).toBeTruthy();
|
||||
expect(device).toBeTruthy();
|
||||
expect(store).toBeTruthy();
|
||||
expect(sendMessage).toBeTruthy();
|
||||
expect(client.plugins.includes(TestPlugin.id)).toBe(true);
|
||||
expect(store.getState().connections).toMatchSnapshot();
|
||||
expect(store.getState().plugins).toMatchSnapshot();
|
||||
sendMessage('inc', {});
|
||||
expect(store.getState().pluginStates).toMatchInlineSnapshot(`
|
||||
const {
|
||||
client,
|
||||
device,
|
||||
store,
|
||||
sendMessage,
|
||||
} = await createMockFlipperWithPlugin(TestPlugin);
|
||||
expect(client).toBeTruthy();
|
||||
expect(device).toBeTruthy();
|
||||
expect(store).toBeTruthy();
|
||||
expect(sendMessage).toBeTruthy();
|
||||
expect(client.plugins.includes(TestPlugin.id)).toBe(true);
|
||||
expect(store.getState().connections).toMatchSnapshot();
|
||||
expect(store.getState().plugins).toMatchSnapshot();
|
||||
sendMessage('inc', {});
|
||||
expect(store.getState().pluginStates).toMatchInlineSnapshot(`
|
||||
Object {
|
||||
"TestApp#Android#MockAndroidDevice#serial#TestPlugin": Object {
|
||||
"count": 1,
|
||||
},
|
||||
}
|
||||
`);
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user