Use Archived device for test, as IOSDevice registers for log listeners and spits errors in tests

Summary:
Instead of using IOSDevice, used ArchivedDevice, as it doesn't instantiate the loglistener which printed erros in the console when one ran the tests.

Look at the attached task.

Reviewed By: passy

Differential Revision: D13941803

fbshipit-source-id: 3e504a02522719985afaad25caf4d2a576bfc338
This commit is contained in:
Pritesh Nandgaonkar
2019-02-05 09:26:43 -08:00
committed by Facebook Github Bot
parent d70e512889
commit dc9160d05c

View File

@@ -6,6 +6,7 @@
*/ */
import {default as BaseDevice} from '../../devices/BaseDevice'; import {default as BaseDevice} from '../../devices/BaseDevice';
import {default as ArchivedDevice} from '../../devices/ArchivedDevice';
import {processStore} from '../exportData'; import {processStore} from '../exportData';
import {IOSDevice} from '../../..'; import {IOSDevice} from '../../..';
import {FlipperDevicePlugin} from '../../plugin.js'; import {FlipperDevicePlugin} from '../../plugin.js';
@@ -44,7 +45,7 @@ function generateClientFromDevice(
} }
test('test generateClientFromDevice helper function', () => { test('test generateClientFromDevice helper function', () => {
const device = new IOSDevice('serial', 'emulator', 'TestiPhone'); const device = new ArchivedDevice('serial', 'emulator', 'TestiPhone', 'iOS');
const client = generateClientFromDevice(device, 'app'); const client = generateClientFromDevice(device, 'app');
expect(client).toEqual({ expect(client).toEqual({
id: 'app#iOS#emulator#serial', id: 'app#iOS#emulator#serial',
@@ -53,7 +54,7 @@ test('test generateClientFromDevice helper function', () => {
}); });
test('test generateClientIdentifier helper function', () => { test('test generateClientIdentifier helper function', () => {
const device = new IOSDevice('serial', 'emulator', 'TestiPhone'); const device = new ArchivedDevice('serial', 'emulator', 'TestiPhone', 'iOS');
const identifier = generateClientIdentifier(device, 'app'); const identifier = generateClientIdentifier(device, 'app');
expect(identifier).toEqual('app#iOS#emulator#serial'); expect(identifier).toEqual('app#iOS#emulator#serial');
}); });
@@ -76,7 +77,7 @@ test('test processStore function for empty state', () => {
test('test processStore function for an iOS device connected', () => { test('test processStore function for an iOS device connected', () => {
const json = processStore( const json = processStore(
[], [],
new IOSDevice('serial', 'emulator', 'TestiPhone'), new ArchivedDevice('serial', 'emulator', 'TestiPhone', 'iOS'),
{}, {},
[], [],
new Map(), new Map(),
@@ -99,7 +100,7 @@ test('test processStore function for an iOS device connected', () => {
}); });
test('test processStore function for an iOS device connected with client plugin data', () => { test('test processStore function for an iOS device connected with client plugin data', () => {
const device = new IOSDevice('serial', 'emulator', 'TestiPhone'); const device = new ArchivedDevice('serial', 'emulator', 'TestiPhone', 'iOS');
const clientIdentifier = generateClientIdentifier(device, 'testapp'); const clientIdentifier = generateClientIdentifier(device, 'testapp');
const json = processStore( const json = processStore(
[], [],
@@ -118,11 +119,17 @@ test('test processStore function for an iOS device connected with client plugin
}); });
test('test processStore function to have only the client for the selected device', () => { test('test processStore function to have only the client for the selected device', () => {
const selectedDevice = new IOSDevice('serial', 'emulator', 'TestiPhone'); const selectedDevice = new ArchivedDevice(
const unselectedDevice = new IOSDevice( 'serial',
'emulator',
'TestiPhone',
'iOS',
);
const unselectedDevice = new ArchivedDevice(
'identifier', 'identifier',
'emulator', 'emulator',
'TestiPhone', 'TestiPhone',
'iOS',
); );
const unselectedDeviceClientIdentifier = generateClientIdentifier( const unselectedDeviceClientIdentifier = generateClientIdentifier(
@@ -169,7 +176,12 @@ test('test processStore function to have only the client for the selected device
}); });
test('test processStore function to have multiple clients for the selected device', () => { test('test processStore function to have multiple clients for the selected device', () => {
const selectedDevice = new IOSDevice('serial', 'emulator', 'TestiPhone'); const selectedDevice = new ArchivedDevice(
'serial',
'emulator',
'TestiPhone',
'iOS',
);
const clientIdentifierApp1 = generateClientIdentifier( const clientIdentifierApp1 = generateClientIdentifier(
selectedDevice, selectedDevice,
@@ -219,7 +231,12 @@ test('test processStore function to have multiple clients for the selected devic
test('test processStore function for device plugin state and no clients', () => { test('test processStore function for device plugin state and no clients', () => {
// Test case to verify that device plugin data is exported even if there are no clients // Test case to verify that device plugin data is exported even if there are no clients
const selectedDevice = new IOSDevice('serial', 'emulator', 'TestiPhone'); const selectedDevice = new ArchivedDevice(
'serial',
'emulator',
'TestiPhone',
'iOS',
);
const json = processStore( const json = processStore(
[], [],
selectedDevice, selectedDevice,
@@ -245,7 +262,12 @@ test('test processStore function for device plugin state and no clients', () =>
test('test processStore function for unselected device plugin state and no clients', () => { test('test processStore function for unselected device plugin state and no clients', () => {
// Test case to verify that device plugin data is exported even if there are no clients // Test case to verify that device plugin data is exported even if there are no clients
const selectedDevice = new IOSDevice('serial', 'emulator', 'TestiPhone'); const selectedDevice = new ArchivedDevice(
'serial',
'emulator',
'TestiPhone',
'iOS',
);
const json = processStore( const json = processStore(
[], [],
selectedDevice, selectedDevice,
@@ -268,7 +290,12 @@ test('test processStore function for unselected device plugin state and no clien
test('test processStore function for notifications for selected device', () => { test('test processStore function for notifications for selected device', () => {
// Test case to verify that device plugin data is exported even if there are no clients // Test case to verify that device plugin data is exported even if there are no clients
const selectedDevice = new IOSDevice('serial', 'emulator', 'TestiPhone'); const selectedDevice = new ArchivedDevice(
'serial',
'emulator',
'TestiPhone',
'iOS',
);
const client = generateClientFromDevice(selectedDevice, 'testapp1'); const client = generateClientFromDevice(selectedDevice, 'testapp1');
const notification = generateNotifications( const notification = generateNotifications(
'notificationID', 'notificationID',
@@ -302,11 +329,17 @@ test('test processStore function for notifications for selected device', () => {
test('test processStore function for notifications for unselected device', () => { test('test processStore function for notifications for unselected device', () => {
// Test case to verify that device plugin data is exported even if there are no clients // Test case to verify that device plugin data is exported even if there are no clients
const selectedDevice = new IOSDevice('serial', 'emulator', 'TestiPhone'); const selectedDevice = new ArchivedDevice(
const unselectedDevice = new IOSDevice( 'serial',
'emulator',
'TestiPhone',
'iOS',
);
const unselectedDevice = new ArchivedDevice(
'identifier', 'identifier',
'emulator', 'emulator',
'TestiPhone', 'TestiPhone',
'iOS',
); );
const client = generateClientFromDevice(selectedDevice, 'testapp1'); const client = generateClientFromDevice(selectedDevice, 'testapp1');