Remove some unhandled rejections in tests
Summary: Fixed several tests that caused uncaught promise rejects to fire after the tests finished. This caused jest to fail if there are too many of them. Reviewed By: aigoncharov Differential Revision: D32118124 fbshipit-source-id: 50734dab6dee2efec7f056940af72858b27b1707
This commit is contained in:
committed by
Facebook GitHub Bot
parent
8f3e729b7b
commit
72ce759e61
@@ -225,7 +225,18 @@ test('new clients replace old ones', async () => {
|
||||
expect(instance.instanceApi.disconnect).toBeCalledTimes(0);
|
||||
|
||||
const client2 = await createClient(device, 'AnotherApp', client.query, true);
|
||||
handleClientConnected(null as any, store, logger, client2);
|
||||
await handleClientConnected(
|
||||
{
|
||||
exec: (async () => {
|
||||
return {
|
||||
success: {}, // {plugins: []},
|
||||
};
|
||||
}) as any,
|
||||
},
|
||||
store,
|
||||
logger,
|
||||
client2,
|
||||
);
|
||||
|
||||
expect(client2.connected.get()).toBe(true);
|
||||
const instance2 = client2.sandyPluginStates.get(plugin.id)!;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
import React from 'react';
|
||||
import {State, Store} from '../reducers/index';
|
||||
import {Logger} from 'flipper-common';
|
||||
import {FlipperServer, Logger} from 'flipper-common';
|
||||
import {FlipperServerImpl} from 'flipper-server-core';
|
||||
import {selectClient} from '../reducers/connections';
|
||||
import Client from '../Client';
|
||||
@@ -168,7 +168,7 @@ export default async (store: Store, logger: Logger) => {
|
||||
};
|
||||
|
||||
export async function handleClientConnected(
|
||||
server: FlipperServerImpl,
|
||||
server: Pick<FlipperServer, 'exec'>,
|
||||
store: Store,
|
||||
logger: Logger,
|
||||
{id, query}: ClientDescription,
|
||||
|
||||
@@ -58,7 +58,7 @@ export default class MockFlipper {
|
||||
private _clients: Client[] = [];
|
||||
private _deviceCounter: number = 0;
|
||||
private _clientCounter: number = 0;
|
||||
private _flipperServer: FlipperServer = createFlipperServerMock();
|
||||
flipperServer: FlipperServer = createFlipperServerMock();
|
||||
|
||||
public get store(): Store {
|
||||
return this._store;
|
||||
@@ -98,7 +98,7 @@ export default class MockFlipper {
|
||||
this._store.dispatch(registerPlugins(plugins ?? []));
|
||||
this._store.dispatch({
|
||||
type: 'SET_FLIPPER_SERVER',
|
||||
payload: this._flipperServer,
|
||||
payload: this.flipperServer,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import BaseDevice from '../devices/BaseDevice';
|
||||
import {Store} from '../reducers/index';
|
||||
import Client from '../Client';
|
||||
|
||||
import {ClientQuery, Logger} from 'flipper-common';
|
||||
import {ClientQuery, FlipperServer, Logger} from 'flipper-common';
|
||||
import {FlipperDevicePlugin, FlipperPlugin, PluginDefinition} from '../plugin';
|
||||
import PluginContainer from '../PluginContainer';
|
||||
import {isDevicePluginDefinition} from '../utils/pluginUtils';
|
||||
@@ -42,6 +42,7 @@ export type MockFlipperResult = {
|
||||
client: Client;
|
||||
device: BaseDevice;
|
||||
store: Store;
|
||||
server: FlipperServer;
|
||||
pluginKey: string;
|
||||
sendError(error: any, client?: Client): void;
|
||||
sendMessage(method: string, params: any, client?: Client): void;
|
||||
@@ -126,6 +127,7 @@ export async function createMockFlipperWithPlugin(
|
||||
});
|
||||
const logger = mockFlipper.logger;
|
||||
const store = mockFlipper.store;
|
||||
const server = mockFlipper.flipperServer;
|
||||
|
||||
const createDevice = (options: Parameters<MockFlipper['createDevice']>[0]) =>
|
||||
mockFlipper.createDevice(options);
|
||||
@@ -206,6 +208,7 @@ export async function createMockFlipperWithPlugin(
|
||||
client,
|
||||
device: device as any,
|
||||
store,
|
||||
server,
|
||||
selectPlugin: selectPluginImpl,
|
||||
sendError(error: any, actualClient = client) {
|
||||
actualClient.onMessage(
|
||||
|
||||
Reference in New Issue
Block a user