mirror of
https://github.com/status-im/react-native.git
synced 2025-01-10 17:45:59 +00:00
48ab5eb436
Summary: At the moment the run-ios command from the react-native cli does only work for simulators. The pull request adds a new option to the existing command: **"--device 'device-name'" which installs and launches an iOS application on a connected device.** This makes it easier to build a test environment using react-native for connected devices. I've tested my code with the following commands: react-native run-ios --device "Not existing device" react-native run-ios --device react-native run-ios --device "name-of-a-simulator" react-native run-ios --device "name-of-connected-device" Output of the first three commands: ![example_error_output](https://cloud.githubusercontent.com/assets/9102810/17669443/f53d5948-630d-11e6-9a80-7df2f352c6a3.png) Additional to the manual command tests i've added a test file 'parseIOSDevicesList-test.js'. I used **ios-deploy** In order to launch and install the .app-bundle on a connected device. ios-deploy on github: Closes https://github.com/facebook/react-native/pull/9414 Differential Revision: D3821638 Pulled By: javache fbshipit-source-id: c07b7bf25283a966e45613a22ed3184bb1aac714
197 lines
6.0 KiB
JavaScript
197 lines
6.0 KiB
JavaScript
/**
|
|
/**
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*/
|
|
'use strict';
|
|
|
|
jest.dontMock('../findMatchingSimulator');
|
|
|
|
const findMatchingSimulator = require('../findMatchingSimulator');
|
|
|
|
describe('findMatchingSimulator', () => {
|
|
it('should find simulator', () => {
|
|
expect(findMatchingSimulator({
|
|
"devices": {
|
|
"iOS 9.2": [
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 4s",
|
|
"udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 5",
|
|
"udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 6",
|
|
"udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 6 (Plus)",
|
|
"udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 6s",
|
|
"udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
'iPhone 6'
|
|
)).toEqual({
|
|
udid: 'BA0D93BD-07E6-4182-9B0A-F60A2474139C',
|
|
name: 'iPhone 6',
|
|
version: 'iOS 9.2'
|
|
});
|
|
});
|
|
|
|
it('should return null if no simulators available', () => {
|
|
expect(findMatchingSimulator({
|
|
"devices": {
|
|
"iOS 9.2": [
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(unavailable, runtime profile not found)",
|
|
"name": "iPhone 4s",
|
|
"udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(unavailable, runtime profile not found)",
|
|
"name": "iPhone 5",
|
|
"udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(unavailable, runtime profile not found)",
|
|
"name": "iPhone 6",
|
|
"udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(unavailable, runtime profile not found)",
|
|
"name": "iPhone 6 (Plus)",
|
|
"udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(unavailable, runtime profile not found)",
|
|
"name": "iPhone 6s",
|
|
"udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
'iPhone 6'
|
|
)).toEqual(null);
|
|
});
|
|
|
|
it('should return null if an odd input', () => {
|
|
expect(findMatchingSimulator('random string input', 'iPhone 6')).toEqual(null);
|
|
});
|
|
|
|
it('should return the first simulator in list if none is defined', () => {
|
|
expect(findMatchingSimulator({
|
|
"devices": {
|
|
"iOS 9.2": [
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(unavailable, runtime profile not found)",
|
|
"name": "iPhone 4s",
|
|
"udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 5",
|
|
"udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 6",
|
|
"udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 6 (Plus)",
|
|
"udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(unavailable, runtime profile not found)",
|
|
"name": "iPhone 6s",
|
|
"udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
null
|
|
)).toEqual({
|
|
udid: '1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB',
|
|
name: 'iPhone 5',
|
|
version: 'iOS 9.2'
|
|
});
|
|
});
|
|
|
|
it('should return the botted simulator in list if none is defined', () => {
|
|
expect(findMatchingSimulator({
|
|
"devices": {
|
|
"iOS 9.2": [
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(unavailable, runtime profile not found)",
|
|
"name": "iPhone 4s",
|
|
"udid": "B9B5E161-416B-43C4-A78F-729CB96CC8C6"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 5",
|
|
"udid": "1CCBBF8B-5773-4EA6-BD6F-C308C87A1ADB"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 6",
|
|
"udid": "BA0D93BD-07E6-4182-9B0A-F60A2474139C"
|
|
},
|
|
{
|
|
"state": "Shutdown",
|
|
"availability": "(available)",
|
|
"name": "iPhone 6 (Plus)",
|
|
"udid": "9564ABEE-9EC2-4B4A-B443-D3710929A45A"
|
|
},
|
|
{
|
|
"state": "Booted",
|
|
"availability": "(available)",
|
|
"name": "iPhone 6s",
|
|
"udid": "D0F29BE7-CC3C-4976-888D-C739B4F50508"
|
|
}
|
|
]
|
|
}
|
|
},
|
|
null
|
|
)).toEqual({
|
|
udid: 'D0F29BE7-CC3C-4976-888D-C739B4F50508',
|
|
name: 'iPhone 6s',
|
|
version: 'iOS 9.2'
|
|
});
|
|
});
|
|
});
|