Start bridge abstraction
Summary: This is just an early start of centralising some ad-hoc logic we've got all over the place right now. Memoised do-we-have-idb calls with concatenated shell invocations. This gives us the opportunity to do a bit of testing, too. Reviewed By: mweststrate Differential Revision: D26694863 fbshipit-source-id: cd2b9883f90397802bbaae6030f7cb3881c565c2
This commit is contained in:
committed by
Facebook GitHub Bot
parent
43242557aa
commit
390f27a137
60
desktop/app/src/utils/__tests__/IOSBridge.node.tsx
Normal file
60
desktop/app/src/utils/__tests__/IOSBridge.node.tsx
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {makeIOSBridge} from '../IOSBridge';
|
||||
import childProcess from 'child_process';
|
||||
import {mocked} from 'ts-jest/utils';
|
||||
|
||||
jest.mock('child_process');
|
||||
const spawn = mocked(childProcess.spawn);
|
||||
|
||||
test('uses xcrun with no idb', async () => {
|
||||
const ib = await makeIOSBridge('');
|
||||
ib.startLogListener('deadbeef');
|
||||
|
||||
expect(spawn).toHaveBeenCalledWith(
|
||||
'xcrun',
|
||||
[
|
||||
'simctl',
|
||||
'spawn',
|
||||
'deadbeef',
|
||||
'log',
|
||||
'stream',
|
||||
'--style',
|
||||
'json',
|
||||
'--predicate',
|
||||
'senderImagePath contains "Containers"',
|
||||
'--debug',
|
||||
'--info',
|
||||
],
|
||||
{},
|
||||
);
|
||||
});
|
||||
|
||||
test('uses idb when present', async () => {
|
||||
const ib = await makeIOSBridge('/usr/local/bin/idb');
|
||||
ib.startLogListener('deadbeef');
|
||||
|
||||
expect(spawn).toHaveBeenCalledWith(
|
||||
'/usr/local/bin/idb',
|
||||
[
|
||||
'log',
|
||||
'--udid',
|
||||
'deadbeef',
|
||||
'--',
|
||||
'--style',
|
||||
'json',
|
||||
'--predicate',
|
||||
'senderImagePath contains "Containers"',
|
||||
'--debug',
|
||||
'--info',
|
||||
],
|
||||
{},
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user