Move exportData.electron.js to tsx
Summary: Migrates `exportdata.electron.js` to tsx Reviewed By: passy Differential Revision: D18379598 fbshipit-source-id: c8fadf23b02ceb28b134df62c7590727a4f03554
This commit is contained in:
committed by
Facebook Github Bot
parent
da25241f7f
commit
ff7d5018ec
@@ -7,16 +7,15 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {default as BaseDevice} from '../../devices/BaseDevice.tsx';
|
import {default as BaseDevice} from '../../devices/BaseDevice';
|
||||||
import {default as ArchivedDevice} from '../../devices/ArchivedDevice.tsx';
|
import {default as ArchivedDevice} from '../../devices/ArchivedDevice';
|
||||||
import {processStore} from '../exportData.tsx';
|
import {processStore} from '../exportData';
|
||||||
import {FlipperDevicePlugin} from '../../plugin.tsx';
|
import {FlipperPlugin, FlipperDevicePlugin} from '../../plugin';
|
||||||
import type {Notification} from '../../plugin.tsx';
|
import {Notification} from '../../plugin';
|
||||||
import type {ClientExport} from '../../Client.tsx';
|
import {ClientExport} from '../../Client';
|
||||||
|
|
||||||
class TestDevicePlugin extends FlipperDevicePlugin {
|
class TestPlugin extends FlipperPlugin<any, any, any> {}
|
||||||
static id = 'TestDevicePlugin';
|
class TestDevicePlugin extends FlipperDevicePlugin<any, any, any> {}
|
||||||
}
|
|
||||||
|
|
||||||
function generateNotifications(
|
function generateNotifications(
|
||||||
id: string,
|
id: string,
|
||||||
@@ -176,10 +175,17 @@ test('test processStore function for an iOS device connected', async () => {
|
|||||||
salt: 'salt',
|
salt: 'salt',
|
||||||
selectedPlugins: [],
|
selectedPlugins: [],
|
||||||
});
|
});
|
||||||
expect(json).toBeDefined();
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {device, clients} = json;
|
const {device, clients} = json;
|
||||||
expect(device).toBeDefined();
|
expect(json.device).toBeDefined();
|
||||||
expect(clients).toEqual([]);
|
expect(clients).toEqual([]);
|
||||||
|
if (!device) {
|
||||||
|
fail('device is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {serial, deviceType, title, os} = device;
|
const {serial, deviceType, title, os} = device;
|
||||||
expect(serial).toEqual('salt-serial');
|
expect(serial).toEqual('salt-serial');
|
||||||
expect(deviceType).toEqual('archivedEmulator');
|
expect(deviceType).toEqual('archivedEmulator');
|
||||||
@@ -203,21 +209,24 @@ test('test processStore function for an iOS device connected with client plugin
|
|||||||
activeNotifications: [],
|
activeNotifications: [],
|
||||||
device,
|
device,
|
||||||
pluginStates: {
|
pluginStates: {
|
||||||
[`${clientIdentifier}#TestDevicePlugin`]: {msg: 'Test plugin'},
|
[`${clientIdentifier}#TestPlugin`]: {msg: 'Test plugin'},
|
||||||
},
|
},
|
||||||
clients: [generateClientFromDevice(device, 'testapp')],
|
clients: [generateClientFromDevice(device, 'testapp')],
|
||||||
devicePlugins: new Map(),
|
devicePlugins: new Map(),
|
||||||
clientPlugins: new Map([['TestDevicePlugin', TestDevicePlugin]]),
|
clientPlugins: new Map([['TestPlugin', TestPlugin]]),
|
||||||
salt: 'salt',
|
salt: 'salt',
|
||||||
selectedPlugins: [],
|
selectedPlugins: [],
|
||||||
});
|
});
|
||||||
expect(json).toBeDefined();
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {pluginStates} = json.store;
|
const {pluginStates} = json.store;
|
||||||
const expectedPluginState = {
|
const expectedPluginState = {
|
||||||
[`${generateClientIdentifierWithSalt(
|
[`${generateClientIdentifierWithSalt(
|
||||||
clientIdentifier,
|
clientIdentifier,
|
||||||
'salt',
|
'salt',
|
||||||
)}#TestDevicePlugin`]: JSON.stringify({
|
)}#TestPlugin`]: JSON.stringify({
|
||||||
msg: 'Test plugin',
|
msg: 'Test plugin',
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -268,12 +277,15 @@ test('test processStore function to have only the client for the selected device
|
|||||||
generateClientFromDevice(unselectedDevice, 'testapp'),
|
generateClientFromDevice(unselectedDevice, 'testapp'),
|
||||||
],
|
],
|
||||||
devicePlugins: new Map(),
|
devicePlugins: new Map(),
|
||||||
clientPlugins: new Map([['TestDevicePlugin', TestDevicePlugin]]),
|
clientPlugins: new Map([['TestDevicePlugin', TestPlugin]]),
|
||||||
salt: 'salt',
|
salt: 'salt',
|
||||||
selectedPlugins: [],
|
selectedPlugins: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(json).toBeDefined();
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {clients} = json;
|
const {clients} = json;
|
||||||
const {pluginStates} = json.store;
|
const {pluginStates} = json.store;
|
||||||
const expectedPluginState = {
|
const expectedPluginState = {
|
||||||
@@ -313,10 +325,10 @@ test('test processStore function to have multiple clients for the selected devic
|
|||||||
activeNotifications: [],
|
activeNotifications: [],
|
||||||
device: selectedDevice,
|
device: selectedDevice,
|
||||||
pluginStates: {
|
pluginStates: {
|
||||||
[clientIdentifierApp1 + '#TestDevicePlugin']: {
|
[clientIdentifierApp1 + '#TestPlugin']: {
|
||||||
msg: 'Test plugin App1',
|
msg: 'Test plugin App1',
|
||||||
},
|
},
|
||||||
[clientIdentifierApp2 + '#TestDevicePlugin']: {
|
[clientIdentifierApp2 + '#TestPlugin']: {
|
||||||
msg: 'Test plugin App2',
|
msg: 'Test plugin App2',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -325,20 +337,24 @@ test('test processStore function to have multiple clients for the selected devic
|
|||||||
generateClientFromDevice(selectedDevice, 'testapp2'),
|
generateClientFromDevice(selectedDevice, 'testapp2'),
|
||||||
],
|
],
|
||||||
devicePlugins: new Map(),
|
devicePlugins: new Map(),
|
||||||
clientPlugins: new Map([['TestDevicePlugin', TestDevicePlugin]]),
|
clientPlugins: new Map([['TestPlugin', TestPlugin]]),
|
||||||
salt: 'salt',
|
salt: 'salt',
|
||||||
selectedPlugins: [],
|
selectedPlugins: [],
|
||||||
});
|
});
|
||||||
expect(json).toBeDefined();
|
|
||||||
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {clients} = json;
|
const {clients} = json;
|
||||||
const {pluginStates} = json.store;
|
const {pluginStates} = json.store;
|
||||||
const expectedPluginState = {
|
const expectedPluginState = {
|
||||||
[generateClientIdentifierWithSalt(clientIdentifierApp1, 'salt') +
|
[generateClientIdentifierWithSalt(clientIdentifierApp1, 'salt') +
|
||||||
'#TestDevicePlugin']: JSON.stringify({
|
'#TestPlugin']: JSON.stringify({
|
||||||
msg: 'Test plugin App1',
|
msg: 'Test plugin App1',
|
||||||
}),
|
}),
|
||||||
[generateClientIdentifierWithSalt(clientIdentifierApp2, 'salt') +
|
[generateClientIdentifierWithSalt(clientIdentifierApp2, 'salt') +
|
||||||
'#TestDevicePlugin']: JSON.stringify({
|
'#TestPlugin']: JSON.stringify({
|
||||||
msg: 'Test plugin App2',
|
msg: 'Test plugin App2',
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -372,7 +388,11 @@ test('test processStore function for device plugin state and no clients', async
|
|||||||
salt: 'salt',
|
salt: 'salt',
|
||||||
selectedPlugins: [],
|
selectedPlugins: [],
|
||||||
});
|
});
|
||||||
expect(json).toBeDefined();
|
|
||||||
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {pluginStates} = json.store;
|
const {pluginStates} = json.store;
|
||||||
const {clients} = json;
|
const {clients} = json;
|
||||||
const expectedPluginState = {
|
const expectedPluginState = {
|
||||||
@@ -405,7 +425,10 @@ test('test processStore function for unselected device plugin state and no clien
|
|||||||
salt: 'salt',
|
salt: 'salt',
|
||||||
selectedPlugins: [],
|
selectedPlugins: [],
|
||||||
});
|
});
|
||||||
expect(json).toBeDefined();
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {pluginStates} = json.store;
|
const {pluginStates} = json.store;
|
||||||
const {clients} = json;
|
const {clients} = json;
|
||||||
expect(pluginStates).toEqual({});
|
expect(pluginStates).toEqual({});
|
||||||
@@ -444,7 +467,10 @@ test('test processStore function for notifications for selected device', async (
|
|||||||
selectedPlugins: [],
|
selectedPlugins: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(json).toBeDefined();
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {pluginStates} = json.store;
|
const {pluginStates} = json.store;
|
||||||
const {clients} = json;
|
const {clients} = json;
|
||||||
expect(pluginStates).toEqual({});
|
expect(pluginStates).toEqual({});
|
||||||
@@ -501,7 +527,10 @@ test('test processStore function for notifications for unselected device', async
|
|||||||
salt: 'salt',
|
salt: 'salt',
|
||||||
selectedPlugins: [],
|
selectedPlugins: [],
|
||||||
});
|
});
|
||||||
expect(json).toBeDefined();
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {pluginStates} = json.store;
|
const {pluginStates} = json.store;
|
||||||
const {clients} = json;
|
const {clients} = json;
|
||||||
expect(pluginStates).toEqual({});
|
expect(pluginStates).toEqual({});
|
||||||
@@ -541,7 +570,10 @@ test('test processStore function for selected plugins', async () => {
|
|||||||
salt: 'salt',
|
salt: 'salt',
|
||||||
selectedPlugins: ['TestDevicePlugin2'],
|
selectedPlugins: ['TestDevicePlugin2'],
|
||||||
});
|
});
|
||||||
expect(json).toBeDefined();
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {pluginStates} = json.store;
|
const {pluginStates} = json.store;
|
||||||
const {clients} = json;
|
const {clients} = json;
|
||||||
expect(pluginStates).toEqual({
|
expect(pluginStates).toEqual({
|
||||||
@@ -588,7 +620,10 @@ test('test processStore function for no selected plugins', async () => {
|
|||||||
selectedPlugins: [],
|
selectedPlugins: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(json).toBeDefined();
|
if (!json) {
|
||||||
|
fail('json is undefined');
|
||||||
|
return;
|
||||||
|
}
|
||||||
const {pluginStates} = json.store;
|
const {pluginStates} = json.store;
|
||||||
const {clients} = json;
|
const {clients} = json;
|
||||||
expect(pluginStates).toEqual({
|
expect(pluginStates).toEqual({
|
||||||
Reference in New Issue
Block a user