Skip to content

Commit

Permalink
Mock xcrun calls (#373)
Browse files Browse the repository at this point in the history
* Mock xcrun calls

* Await prepareIosOpts
  • Loading branch information
imurchie committed May 3, 2019
1 parent ab17664 commit a17e317
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 13 deletions.
2 changes: 2 additions & 0 deletions test/unit/device-specs.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { IosDriver } from '../../lib/driver';
import { uiauto } from '../..';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import sinon from 'sinon';

chai.should();
chai.use(chaiAsPromised);

const PLUS_HEIGHT = 736;
const NONPLUS_HEIGHT = 568;
Expand Down
6 changes: 6 additions & 0 deletions test/unit/file-movement-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { IosDriver } from '../..';
import sinon from 'sinon';
import path from 'path';
import { tempDir, fs, zip } from 'appium-support';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';


chai.should();
chai.use(chaiAsPromised);

describe('File Movement', function () {
let driver = new IosDriver();
Expand Down
34 changes: 21 additions & 13 deletions test/unit/utils-specs.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,34 @@
// transpile:mocha

import * as utils from '../../lib/utils';
import chai from 'chai';
import chaiAsPromised from 'chai-as-promised';
import { withMocks } from 'appium-test-support';
import xcode from 'appium-xcode';


chai.should();
chai.use(chaiAsPromised);

describe('prepareIosOpts', function () {
it('should use instruments without delay by default', function () {
let opts = {};
utils.prepareIosOpts(opts);
describe('prepareIosOpts', withMocks({xcode}, (mocks) => {
beforeEach(function () {
mocks.xcode.expects('getMaxIOSSDK')
.once().returns('9.3');
});
afterEach(function () {
mocks.verify();
});
it('should use instruments without delay by default', async function () {
const opts = {};
await utils.prepareIosOpts(opts);
opts.withoutDelay.should.be.true;
});
it('should use instruments without delay if explicitly not using native instruments', function () {
let opts = {nativeInstrumentsLib: false};
utils.prepareIosOpts(opts);
it('should use instruments without delay if explicitly not using native instruments', async function () {
const opts = {nativeInstrumentsLib: false};
await utils.prepareIosOpts(opts);
opts.withoutDelay.should.be.true;
});
it('should not use instruments without delay if using native intruments', function () {
let opts = {nativeInstrumentsLib: true};
utils.prepareIosOpts(opts);
it('should not use instruments without delay if using native intruments', async function () {
const opts = {nativeInstrumentsLib: true};
await utils.prepareIosOpts(opts);
opts.withoutDelay.should.be.false;
});
});
}));

0 comments on commit a17e317

Please sign in to comment.