diff --git a/desktop/app/src/__tests__/PluginContainer.node.tsx b/desktop/app/src/__tests__/PluginContainer.node.tsx
index 01305e033..9d3367713 100644
--- a/desktop/app/src/__tests__/PluginContainer.node.tsx
+++ b/desktop/app/src/__tests__/PluginContainer.node.tsx
@@ -13,7 +13,7 @@ import {FlipperPlugin} from '../plugin';
import {renderMockFlipperWithPlugin} from '../test-utils/createMockFlipperWithPlugin';
import {
SandyPluginDefinition,
- FlipperClient,
+ PluginClient,
TestUtils,
usePlugin,
createState,
@@ -113,7 +113,7 @@ test('PluginContainer can render Sandy plugins', async () => {
return
Hello from Sandy
;
}
- const plugin = (client: FlipperClient) => {
+ const plugin = (client: PluginClient) => {
const connectedStub = jest.fn();
const disconnectedStub = jest.fn();
const activatedStub = jest.fn();
@@ -254,7 +254,7 @@ test('PluginContainer triggers correct lifecycles for background plugin', async
return Hello from Sandy
;
}
- const plugin = (client: FlipperClient) => {
+ const plugin = (client: PluginClient) => {
const connectedStub = jest.fn();
const disconnectedStub = 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 () => {
const linksSeen: any[] = [];
- const plugin = (client: FlipperClient) => {
+ const plugin = (client: PluginClient) => {
const linkState = createState('');
client.onDeepLink((link) => {
linksSeen.push(link);
diff --git a/desktop/app/src/reducers/__tests__/sandyplugins.node.tsx b/desktop/app/src/reducers/__tests__/sandyplugins.node.tsx
index 36df06d30..ec8d6c036 100644
--- a/desktop/app/src/reducers/__tests__/sandyplugins.node.tsx
+++ b/desktop/app/src/reducers/__tests__/sandyplugins.node.tsx
@@ -14,7 +14,7 @@ import {registerPlugins} from '../../reducers/plugins';
import {
SandyPluginDefinition,
SandyPluginInstance,
- FlipperClient,
+ PluginClient,
TestUtils,
} from 'flipper-plugin';
@@ -30,7 +30,7 @@ beforeEach(() => {
initialized = false;
});
-function plugin(client: FlipperClient) {
+function plugin(client: PluginClient) {
const connectStub = jest.fn();
const disconnectStub = jest.fn();
const destroyStub = jest.fn();
diff --git a/desktop/app/src/utils/__tests__/exportData.node.tsx b/desktop/app/src/utils/__tests__/exportData.node.tsx
index 0129704a2..d2e985ec6 100644
--- a/desktop/app/src/utils/__tests__/exportData.node.tsx
+++ b/desktop/app/src/utils/__tests__/exportData.node.tsx
@@ -26,7 +26,7 @@ import {
TestUtils,
SandyPluginDefinition,
createState,
- FlipperClient,
+ PluginClient,
} from 'flipper-plugin';
import {selectPlugin} from '../../reducers/connections';
@@ -1043,7 +1043,7 @@ const sandyTestPlugin = new SandyPluginDefinition(
TestUtils.createMockPluginDetails(),
{
plugin(
- client: FlipperClient<{
+ client: PluginClient<{
inc: {};
}>,
) {
diff --git a/desktop/app/src/utils/__tests__/messageQueueSandy.node.tsx b/desktop/app/src/utils/__tests__/messageQueueSandy.node.tsx
index 1a33b87b1..9aa5a712d 100644
--- a/desktop/app/src/utils/__tests__/messageQueueSandy.node.tsx
+++ b/desktop/app/src/utils/__tests__/messageQueueSandy.node.tsx
@@ -23,7 +23,7 @@ import {registerPlugins} from '../../reducers/plugins';
import {
SandyPluginDefinition,
TestUtils,
- FlipperClient,
+ PluginClient,
SandyPluginInstance,
} from 'flipper-plugin';
@@ -33,7 +33,7 @@ type Events = {
};
};
-function plugin(client: FlipperClient) {
+function plugin(client: PluginClient) {
const state = {
count: 0,
};
diff --git a/desktop/flipper-plugin/src/index.ts b/desktop/flipper-plugin/src/index.ts
index 641ae5854..8449bbc97 100644
--- a/desktop/flipper-plugin/src/index.ts
+++ b/desktop/flipper-plugin/src/index.ts
@@ -10,10 +10,7 @@
import './plugin/PluginBase';
import * as TestUtilites from './test-utils/test-utils';
-export {
- SandyPluginInstance,
- PluginClient as FlipperClient,
-} from './plugin/Plugin';
+export {SandyPluginInstance, PluginClient} from './plugin/Plugin';
export {
Device,
DeviceLogEntry,
diff --git a/desktop/jest.config.js b/desktop/jest.config.js
index 636c0c078..96d0bbee0 100644
--- a/desktop/jest.config.js
+++ b/desktop/jest.config.js
@@ -22,6 +22,6 @@ module.exports = {
},
clearMocks: true,
coverageReporters: ['json-summary', 'lcov', 'html'],
- testMatch: ['**/**.node.(js|jsx|ts|tsx)'],
+ testMatch: ['**/**.(node|spec).(js|jsx|ts|tsx)'],
testEnvironment: 'jest-environment-jsdom-sixteen',
};
diff --git a/desktop/plugins/seamammals/src/__tests__/seammammals.node.tsx b/desktop/plugins/seamammals/src/__tests__/seamammals.spec.tsx
similarity index 80%
rename from desktop/plugins/seamammals/src/__tests__/seammammals.node.tsx
rename to desktop/plugins/seamammals/src/__tests__/seamammals.spec.tsx
index 41080d0ef..9b35a2e84 100644
--- a/desktop/plugins/seamammals/src/__tests__/seammammals.node.tsx
+++ b/desktop/plugins/seamammals/src/__tests__/seamammals.spec.tsx
@@ -37,20 +37,20 @@ import {act} from '@testing-library/react';
}
import {TestUtils} from 'flipper-plugin';
-import * as MammalsPlugin from '../';
+import * as MammalsPlugin from '..';
test('It can store rows', () => {
- const {instance, ...plugin} = TestUtils.startPlugin(MammalsPlugin);
+ const {instance, sendEvent} = TestUtils.startPlugin(MammalsPlugin);
expect(instance.rows.get()).toEqual({});
expect(instance.selectedID.get()).toBeNull();
- plugin.sendEvent('newRow', {
+ sendEvent('newRow', {
id: 1,
title: 'Dolphin',
url: 'http://dolphin.png',
});
- plugin.sendEvent('newRow', {
+ sendEvent('newRow', {
id: 2,
title: 'Turtle',
url: 'http://turtle.png',
@@ -73,19 +73,23 @@ test('It can store rows', () => {
});
test('It can have selection and render details', async () => {
- const {instance, renderer, act, ...plugin} = TestUtils.renderPlugin(
- MammalsPlugin,
- );
+ const {
+ instance,
+ renderer,
+ act,
+ sendEvent,
+ exportState,
+ } = TestUtils.renderPlugin(MammalsPlugin);
expect(instance.rows.get()).toEqual({});
expect(instance.selectedID.get()).toBeNull();
- plugin.sendEvent('newRow', {
+ sendEvent('newRow', {
id: 1,
title: 'Dolphin',
url: 'http://dolphin.png',
});
- plugin.sendEvent('newRow', {
+ sendEvent('newRow', {
id: 2,
title: 'Turtle',
url: 'http://turtle.png',
@@ -121,21 +125,19 @@ test('It can have selection and render details', async () => {
expect(await renderer.findByText('Extras')).not.toBeNull();
// Verify export
- expect(plugin.exportState()).toMatchInlineSnapshot(`
- Object {
- "rows": Object {
- "1": Object {
- "id": 1,
- "title": "Dolphin",
- "url": "http://dolphin.png",
- },
- "2": Object {
- "id": 2,
- "title": "Turtle",
- "url": "http://turtle.png",
- },
+ expect(exportState()).toEqual({
+ rows: {
+ '1': {
+ id: 1,
+ title: 'Dolphin',
+ url: 'http://dolphin.png',
},
- "selection": "2",
- }
- `);
+ '2': {
+ id: 2,
+ title: 'Turtle',
+ url: 'http://turtle.png',
+ },
+ },
+ selection: '2',
+ });
});
diff --git a/desktop/plugins/seamammals/src/index.tsx b/desktop/plugins/seamammals/src/index.tsx
index 4cb21c788..c616a201d 100644
--- a/desktop/plugins/seamammals/src/index.tsx
+++ b/desktop/plugins/seamammals/src/index.tsx
@@ -19,12 +19,10 @@ import {
} from 'flipper';
import React, {memo} from 'react';
-import {FlipperClient, usePlugin, createState, useValue} from 'flipper-plugin';
-
-type Id = number;
+import {PluginClient, usePlugin, createState, useValue} from 'flipper-plugin';
type Row = {
- id: Id;
+ id: number;
title: string;
url: string;
};
@@ -33,20 +31,8 @@ type Events = {
newRow: Row;
};
-function renderSidebar(row: Row) {
- return (
-
-
-
- );
-}
-
-type PersistedState = {
- [key: string]: Row;
-};
-
-export function plugin(client: FlipperClient) {
- const rows = createState({}, {persist: 'rows'});
+export function plugin(client: PluginClient) {
+ const rows = createState>({}, {persist: 'rows'});
const selectedID = createState(null, {persist: 'selection'});
client.addMenuEntry(
@@ -90,8 +76,8 @@ export function plugin(client: FlipperClient) {
export function Component() {
const instance = usePlugin(plugin);
- const selectedID = useValue(instance.selectedID);
const rows = useValue(instance.rows);
+ const selectedID = useValue(instance.selectedID);
return (
@@ -110,6 +96,14 @@ export function Component() {
);
}
+function renderSidebar(row: Row) {
+ return (
+
+
+
+ );
+}
+
type CardProps = {
onSelect: (id: number) => void;
selected: boolean;
diff --git a/desktop/plugins/sections/src/index.tsx b/desktop/plugins/sections/src/index.tsx
index 2508f2a49..65d39ebbf 100644
--- a/desktop/plugins/sections/src/index.tsx
+++ b/desktop/plugins/sections/src/index.tsx
@@ -37,7 +37,7 @@ import {
Layout,
} from 'flipper';
-import {FlipperClient, createState, usePlugin, useValue} from 'flipper-plugin';
+import {PluginClient, createState, usePlugin, useValue} from 'flipper-plugin';
const Waiting = styled(FlexBox)({
width: '100%',
@@ -74,7 +74,7 @@ type FocusInfo = {
treeNodeIndexPath?: number[];
};
-export function plugin(client: FlipperClient) {
+export function plugin(client: PluginClient) {
const generations = createState<{[id: string]: TreeGeneration}>(
{},
{persist: 'generations'},