Some renames
Summary: Some non-semantic changes. Mostly an earlier rename that was accidentally done only locally rather than across the codebase Also support `.spec` test extension, which is more idiomatic Jest, since we don't use the `.node` and `.electron` distinction anymore anyway. Reviewed By: jknoxville Differential Revision: D22976438 fbshipit-source-id: f3abedb36cbac1e835295177117ccbca492a67a1
This commit is contained in:
committed by
Facebook GitHub Bot
parent
bce3d48e71
commit
744fe01922
@@ -13,7 +13,7 @@ import {FlipperPlugin} from '../plugin';
|
|||||||
import {renderMockFlipperWithPlugin} from '../test-utils/createMockFlipperWithPlugin';
|
import {renderMockFlipperWithPlugin} from '../test-utils/createMockFlipperWithPlugin';
|
||||||
import {
|
import {
|
||||||
SandyPluginDefinition,
|
SandyPluginDefinition,
|
||||||
FlipperClient,
|
PluginClient,
|
||||||
TestUtils,
|
TestUtils,
|
||||||
usePlugin,
|
usePlugin,
|
||||||
createState,
|
createState,
|
||||||
@@ -113,7 +113,7 @@ test('PluginContainer can render Sandy plugins', async () => {
|
|||||||
return <div>Hello from Sandy</div>;
|
return <div>Hello from Sandy</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const plugin = (client: FlipperClient) => {
|
const plugin = (client: PluginClient) => {
|
||||||
const connectedStub = jest.fn();
|
const connectedStub = jest.fn();
|
||||||
const disconnectedStub = jest.fn();
|
const disconnectedStub = jest.fn();
|
||||||
const activatedStub = jest.fn();
|
const activatedStub = jest.fn();
|
||||||
@@ -254,7 +254,7 @@ test('PluginContainer triggers correct lifecycles for background plugin', async
|
|||||||
return <div>Hello from Sandy</div>;
|
return <div>Hello from Sandy</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const plugin = (client: FlipperClient) => {
|
const plugin = (client: PluginClient) => {
|
||||||
const connectedStub = jest.fn();
|
const connectedStub = jest.fn();
|
||||||
const disconnectedStub = jest.fn();
|
const disconnectedStub = jest.fn();
|
||||||
const activatedStub = jest.fn();
|
const activatedStub = jest.fn();
|
||||||
@@ -396,7 +396,7 @@ test('PluginContainer triggers correct lifecycles for background plugin', async
|
|||||||
test('PluginContainer + Sandy plugin supports deeplink', async () => {
|
test('PluginContainer + Sandy plugin supports deeplink', async () => {
|
||||||
const linksSeen: any[] = [];
|
const linksSeen: any[] = [];
|
||||||
|
|
||||||
const plugin = (client: FlipperClient) => {
|
const plugin = (client: PluginClient) => {
|
||||||
const linkState = createState('');
|
const linkState = createState('');
|
||||||
client.onDeepLink((link) => {
|
client.onDeepLink((link) => {
|
||||||
linksSeen.push(link);
|
linksSeen.push(link);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {registerPlugins} from '../../reducers/plugins';
|
|||||||
import {
|
import {
|
||||||
SandyPluginDefinition,
|
SandyPluginDefinition,
|
||||||
SandyPluginInstance,
|
SandyPluginInstance,
|
||||||
FlipperClient,
|
PluginClient,
|
||||||
TestUtils,
|
TestUtils,
|
||||||
} from 'flipper-plugin';
|
} from 'flipper-plugin';
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ beforeEach(() => {
|
|||||||
initialized = false;
|
initialized = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
function plugin(client: FlipperClient<any, any>) {
|
function plugin(client: PluginClient<any, any>) {
|
||||||
const connectStub = jest.fn();
|
const connectStub = jest.fn();
|
||||||
const disconnectStub = jest.fn();
|
const disconnectStub = jest.fn();
|
||||||
const destroyStub = jest.fn();
|
const destroyStub = jest.fn();
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import {
|
|||||||
TestUtils,
|
TestUtils,
|
||||||
SandyPluginDefinition,
|
SandyPluginDefinition,
|
||||||
createState,
|
createState,
|
||||||
FlipperClient,
|
PluginClient,
|
||||||
} from 'flipper-plugin';
|
} from 'flipper-plugin';
|
||||||
import {selectPlugin} from '../../reducers/connections';
|
import {selectPlugin} from '../../reducers/connections';
|
||||||
|
|
||||||
@@ -1043,7 +1043,7 @@ const sandyTestPlugin = new SandyPluginDefinition(
|
|||||||
TestUtils.createMockPluginDetails(),
|
TestUtils.createMockPluginDetails(),
|
||||||
{
|
{
|
||||||
plugin(
|
plugin(
|
||||||
client: FlipperClient<{
|
client: PluginClient<{
|
||||||
inc: {};
|
inc: {};
|
||||||
}>,
|
}>,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {registerPlugins} from '../../reducers/plugins';
|
|||||||
import {
|
import {
|
||||||
SandyPluginDefinition,
|
SandyPluginDefinition,
|
||||||
TestUtils,
|
TestUtils,
|
||||||
FlipperClient,
|
PluginClient,
|
||||||
SandyPluginInstance,
|
SandyPluginInstance,
|
||||||
} from 'flipper-plugin';
|
} from 'flipper-plugin';
|
||||||
|
|
||||||
@@ -33,7 +33,7 @@ type Events = {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function plugin(client: FlipperClient<Events, {}>) {
|
function plugin(client: PluginClient<Events, {}>) {
|
||||||
const state = {
|
const state = {
|
||||||
count: 0,
|
count: 0,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,10 +10,7 @@
|
|||||||
import './plugin/PluginBase';
|
import './plugin/PluginBase';
|
||||||
import * as TestUtilites from './test-utils/test-utils';
|
import * as TestUtilites from './test-utils/test-utils';
|
||||||
|
|
||||||
export {
|
export {SandyPluginInstance, PluginClient} from './plugin/Plugin';
|
||||||
SandyPluginInstance,
|
|
||||||
PluginClient as FlipperClient,
|
|
||||||
} from './plugin/Plugin';
|
|
||||||
export {
|
export {
|
||||||
Device,
|
Device,
|
||||||
DeviceLogEntry,
|
DeviceLogEntry,
|
||||||
|
|||||||
@@ -22,6 +22,6 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
clearMocks: true,
|
clearMocks: true,
|
||||||
coverageReporters: ['json-summary', 'lcov', 'html'],
|
coverageReporters: ['json-summary', 'lcov', 'html'],
|
||||||
testMatch: ['**/**.node.(js|jsx|ts|tsx)'],
|
testMatch: ['**/**.(node|spec).(js|jsx|ts|tsx)'],
|
||||||
testEnvironment: 'jest-environment-jsdom-sixteen',
|
testEnvironment: 'jest-environment-jsdom-sixteen',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,20 +37,20 @@ import {act} from '@testing-library/react';
|
|||||||
}
|
}
|
||||||
|
|
||||||
import {TestUtils} from 'flipper-plugin';
|
import {TestUtils} from 'flipper-plugin';
|
||||||
import * as MammalsPlugin from '../';
|
import * as MammalsPlugin from '..';
|
||||||
|
|
||||||
test('It can store rows', () => {
|
test('It can store rows', () => {
|
||||||
const {instance, ...plugin} = TestUtils.startPlugin(MammalsPlugin);
|
const {instance, sendEvent} = TestUtils.startPlugin(MammalsPlugin);
|
||||||
|
|
||||||
expect(instance.rows.get()).toEqual({});
|
expect(instance.rows.get()).toEqual({});
|
||||||
expect(instance.selectedID.get()).toBeNull();
|
expect(instance.selectedID.get()).toBeNull();
|
||||||
|
|
||||||
plugin.sendEvent('newRow', {
|
sendEvent('newRow', {
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'Dolphin',
|
title: 'Dolphin',
|
||||||
url: 'http://dolphin.png',
|
url: 'http://dolphin.png',
|
||||||
});
|
});
|
||||||
plugin.sendEvent('newRow', {
|
sendEvent('newRow', {
|
||||||
id: 2,
|
id: 2,
|
||||||
title: 'Turtle',
|
title: 'Turtle',
|
||||||
url: 'http://turtle.png',
|
url: 'http://turtle.png',
|
||||||
@@ -73,19 +73,23 @@ test('It can store rows', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('It can have selection and render details', async () => {
|
test('It can have selection and render details', async () => {
|
||||||
const {instance, renderer, act, ...plugin} = TestUtils.renderPlugin(
|
const {
|
||||||
MammalsPlugin,
|
instance,
|
||||||
);
|
renderer,
|
||||||
|
act,
|
||||||
|
sendEvent,
|
||||||
|
exportState,
|
||||||
|
} = TestUtils.renderPlugin(MammalsPlugin);
|
||||||
|
|
||||||
expect(instance.rows.get()).toEqual({});
|
expect(instance.rows.get()).toEqual({});
|
||||||
expect(instance.selectedID.get()).toBeNull();
|
expect(instance.selectedID.get()).toBeNull();
|
||||||
|
|
||||||
plugin.sendEvent('newRow', {
|
sendEvent('newRow', {
|
||||||
id: 1,
|
id: 1,
|
||||||
title: 'Dolphin',
|
title: 'Dolphin',
|
||||||
url: 'http://dolphin.png',
|
url: 'http://dolphin.png',
|
||||||
});
|
});
|
||||||
plugin.sendEvent('newRow', {
|
sendEvent('newRow', {
|
||||||
id: 2,
|
id: 2,
|
||||||
title: 'Turtle',
|
title: 'Turtle',
|
||||||
url: 'http://turtle.png',
|
url: 'http://turtle.png',
|
||||||
@@ -121,21 +125,19 @@ test('It can have selection and render details', async () => {
|
|||||||
expect(await renderer.findByText('Extras')).not.toBeNull();
|
expect(await renderer.findByText('Extras')).not.toBeNull();
|
||||||
|
|
||||||
// Verify export
|
// Verify export
|
||||||
expect(plugin.exportState()).toMatchInlineSnapshot(`
|
expect(exportState()).toEqual({
|
||||||
Object {
|
rows: {
|
||||||
"rows": Object {
|
'1': {
|
||||||
"1": Object {
|
id: 1,
|
||||||
"id": 1,
|
title: 'Dolphin',
|
||||||
"title": "Dolphin",
|
url: 'http://dolphin.png',
|
||||||
"url": "http://dolphin.png",
|
|
||||||
},
|
|
||||||
"2": Object {
|
|
||||||
"id": 2,
|
|
||||||
"title": "Turtle",
|
|
||||||
"url": "http://turtle.png",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
"selection": "2",
|
'2': {
|
||||||
}
|
id: 2,
|
||||||
`);
|
title: 'Turtle',
|
||||||
|
url: 'http://turtle.png',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
selection: '2',
|
||||||
|
});
|
||||||
});
|
});
|
||||||
@@ -19,12 +19,10 @@ import {
|
|||||||
} from 'flipper';
|
} from 'flipper';
|
||||||
import React, {memo} from 'react';
|
import React, {memo} from 'react';
|
||||||
|
|
||||||
import {FlipperClient, usePlugin, createState, useValue} from 'flipper-plugin';
|
import {PluginClient, usePlugin, createState, useValue} from 'flipper-plugin';
|
||||||
|
|
||||||
type Id = number;
|
|
||||||
|
|
||||||
type Row = {
|
type Row = {
|
||||||
id: Id;
|
id: number;
|
||||||
title: string;
|
title: string;
|
||||||
url: string;
|
url: string;
|
||||||
};
|
};
|
||||||
@@ -33,20 +31,8 @@ type Events = {
|
|||||||
newRow: Row;
|
newRow: Row;
|
||||||
};
|
};
|
||||||
|
|
||||||
function renderSidebar(row: Row) {
|
export function plugin(client: PluginClient<Events, {}>) {
|
||||||
return (
|
const rows = createState<Record<string, Row>>({}, {persist: 'rows'});
|
||||||
<Panel floating={false} heading={'Extras'}>
|
|
||||||
<ManagedDataInspector data={row} expandRoot={true} />
|
|
||||||
</Panel>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
type PersistedState = {
|
|
||||||
[key: string]: Row;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function plugin(client: FlipperClient<Events, {}>) {
|
|
||||||
const rows = createState<PersistedState>({}, {persist: 'rows'});
|
|
||||||
const selectedID = createState<string | null>(null, {persist: 'selection'});
|
const selectedID = createState<string | null>(null, {persist: 'selection'});
|
||||||
|
|
||||||
client.addMenuEntry(
|
client.addMenuEntry(
|
||||||
@@ -90,8 +76,8 @@ export function plugin(client: FlipperClient<Events, {}>) {
|
|||||||
|
|
||||||
export function Component() {
|
export function Component() {
|
||||||
const instance = usePlugin(plugin);
|
const instance = usePlugin(plugin);
|
||||||
const selectedID = useValue(instance.selectedID);
|
|
||||||
const rows = useValue(instance.rows);
|
const rows = useValue(instance.rows);
|
||||||
|
const selectedID = useValue(instance.selectedID);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
@@ -110,6 +96,14 @@ export function Component() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderSidebar(row: Row) {
|
||||||
|
return (
|
||||||
|
<Panel floating={false} heading={'Extras'}>
|
||||||
|
<ManagedDataInspector data={row} expandRoot={true} />
|
||||||
|
</Panel>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
type CardProps = {
|
type CardProps = {
|
||||||
onSelect: (id: number) => void;
|
onSelect: (id: number) => void;
|
||||||
selected: boolean;
|
selected: boolean;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import {
|
|||||||
Layout,
|
Layout,
|
||||||
} from 'flipper';
|
} from 'flipper';
|
||||||
|
|
||||||
import {FlipperClient, createState, usePlugin, useValue} from 'flipper-plugin';
|
import {PluginClient, createState, usePlugin, useValue} from 'flipper-plugin';
|
||||||
|
|
||||||
const Waiting = styled(FlexBox)({
|
const Waiting = styled(FlexBox)({
|
||||||
width: '100%',
|
width: '100%',
|
||||||
@@ -74,7 +74,7 @@ type FocusInfo = {
|
|||||||
treeNodeIndexPath?: number[];
|
treeNodeIndexPath?: number[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export function plugin(client: FlipperClient<Events, {}>) {
|
export function plugin(client: PluginClient<Events, {}>) {
|
||||||
const generations = createState<{[id: string]: TreeGeneration}>(
|
const generations = createState<{[id: string]: TreeGeneration}>(
|
||||||
{},
|
{},
|
||||||
{persist: 'generations'},
|
{persist: 'generations'},
|
||||||
|
|||||||
Reference in New Issue
Block a user