From 6ffdde7e98368b4f57ff611a22ee45e98b23a4eb Mon Sep 17 00:00:00 2001 From: Nitkalya Wiriyanuparb Date: Sun, 6 Oct 2019 01:08:46 +1300 Subject: [PATCH] Add test for start command --- test/commands/start.test.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/test/commands/start.test.js b/test/commands/start.test.js index daea028..342187e 100644 --- a/test/commands/start.test.js +++ b/test/commands/start.test.js @@ -1,2 +1,28 @@ -test('test', function () { +const TheCommand = require('../../src/commands/start') + +jest.mock('simctl') +const simctl = require('simctl') + +let command +beforeEach(() => { + command = new TheCommand([]) +}) + +test('start run', function () { + const json = fixtureJson('simctl-list.json') + const deviceType = 'com.apple.CoreSimulator.SimDeviceType.iPhone-SE,iOS 12.1' + const availbleDevice = json.devices['iOS 12.1'] + .find(({ isAvailable, name }) => isAvailable && name === 'iPhone SE') + + simctl.list = jest.fn(() => { + return { + json + } + }) + simctl.extensions = { start: jest.fn() } + + command.argv = ['--devicetypeid', deviceType] + return command.run().then((result) => { + expect(simctl.extensions.start).toHaveBeenCalledWith(availbleDevice.udid) + }) })