Move FlipperServer initialisation out of flipper-core
Summary: This diff makes sure flipper-ui-core no longer depends on flipper-server-core. Currently server config is still transferred from UI to server, which doesn't really make sense in future scenarios where server might start before client, but will address that separately Reviewed By: timur-valiev, aigoncharov Differential Revision: D32462835 fbshipit-source-id: 498a944256ba1aabbf963b896953e64d11e27214
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d48f22b8dc
commit
eed19b3a3d
@@ -40,7 +40,11 @@ import {stubLogger} from '../utils/Logger';
|
||||
import {Idler} from '../utils/Idler';
|
||||
import {createState} from '../state/atom';
|
||||
import baseMockConsole from 'jest-mock-console';
|
||||
import {DeviceLogEntry} from 'flipper-common';
|
||||
import {
|
||||
DeviceLogEntry,
|
||||
FlipperServer,
|
||||
FlipperServerCommands,
|
||||
} from 'flipper-common';
|
||||
|
||||
type Renderer = RenderResult<typeof queries>;
|
||||
|
||||
@@ -581,3 +585,26 @@ export function mockConsole() {
|
||||
}
|
||||
|
||||
export type MockedConsole = ReturnType<typeof mockConsole>;
|
||||
|
||||
export function createFlipperServerMock(
|
||||
overrides?: Partial<FlipperServerCommands>,
|
||||
): FlipperServer {
|
||||
return {
|
||||
async start() {},
|
||||
on: jest.fn(),
|
||||
off: jest.fn(),
|
||||
exec: jest
|
||||
.fn()
|
||||
.mockImplementation(
|
||||
(cmd: keyof FlipperServerCommands, ...args: any[]) => {
|
||||
if (overrides?.[cmd]) {
|
||||
return (overrides[cmd] as any)(...args);
|
||||
}
|
||||
return Promise.reject(
|
||||
new Error(`FlipperServerMock exec not implemented: ${cmd}}`),
|
||||
);
|
||||
},
|
||||
),
|
||||
close: jest.fn(),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user