From 80c991998540faad464ba764df612a443db35ff2 Mon Sep 17 00:00:00 2001 From: Christopher Hiller Date: Tue, 18 May 2021 12:49:54 -0700 Subject: [PATCH] fix(doctor): use @appium/test-support --- packages/doctor/package.json | 3 +- packages/doctor/test/android-specs.js | 2 +- packages/doctor/test/demo-specs.js | 2 +- packages/doctor/test/dev-specs.js | 2 +- packages/doctor/test/doctor-specs.js | 2 +- packages/doctor/test/general-specs.js | 2 +- packages/doctor/test/ios-specs.js | 34 ++++++++++----------- packages/doctor/test/node-detector-specs.js | 2 +- packages/doctor/test/prompt-specs.js | 2 +- 9 files changed, 26 insertions(+), 25 deletions(-) diff --git a/packages/doctor/package.json b/packages/doctor/package.json index 41bb137a5..bef506431 100644 --- a/packages/doctor/package.json +++ b/packages/doctor/package.json @@ -44,7 +44,8 @@ "yargs": "^17.0.0" }, "devDependencies": { - "@appium/gulp-plugins": "^5.1.1" + "@appium/gulp-plugins": "^5.1.1", + "@appium/test-support": "^1.3.3" }, "engines": { "node": ">=10", diff --git a/packages/doctor/test/android-specs.js b/packages/doctor/test/android-specs.js index e2a6eaf2f..2560000f9 100644 --- a/packages/doctor/test/android-specs.js +++ b/packages/doctor/test/android-specs.js @@ -6,7 +6,7 @@ import * as adb from 'appium-adb'; import * as utils from '../lib/utils'; import * as tp from 'teen_process'; import chai from 'chai'; -import { withMocks, stubEnv } from 'appium-test-support'; +import { withMocks, stubEnv } from '@appium/test-support'; import B from 'bluebird'; import {removeColors} from './helper'; diff --git a/packages/doctor/test/demo-specs.js b/packages/doctor/test/demo-specs.js index fe3fdb49c..deccb2309 100644 --- a/packages/doctor/test/demo-specs.js +++ b/packages/doctor/test/demo-specs.js @@ -8,7 +8,7 @@ import * as tp from 'teen_process'; import * as prompt from '../lib/prompt'; import log from '../lib/logger'; import { FixSkippedError } from '../lib/doctor'; -import { withMocks, withSandbox, stubLog } from 'appium-test-support'; +import { withMocks, withSandbox, stubLog } from '@appium/test-support'; import B from 'bluebird'; diff --git a/packages/doctor/test/dev-specs.js b/packages/doctor/test/dev-specs.js index daac829fb..e52913d3f 100644 --- a/packages/doctor/test/dev-specs.js +++ b/packages/doctor/test/dev-specs.js @@ -4,7 +4,7 @@ import { BinaryIsInPathCheck, AndroidSdkExists } from '../lib/dev'; import { fs } from 'appium-support'; import * as tp from 'teen_process'; import chai from 'chai'; -import { withMocks, stubEnv } from 'appium-test-support'; +import { withMocks, stubEnv } from '@appium/test-support'; import B from 'bluebird'; import { removeColors } from './helper'; diff --git a/packages/doctor/test/doctor-specs.js b/packages/doctor/test/doctor-specs.js index 8b0f8a02c..bb9853158 100644 --- a/packages/doctor/test/doctor-specs.js +++ b/packages/doctor/test/doctor-specs.js @@ -2,7 +2,7 @@ import { Doctor, DoctorCheck, FixSkippedError } from '../lib/doctor'; import chai from 'chai'; -import { withSandbox, stubLog } from 'appium-test-support'; +import { withSandbox, stubLog } from '@appium/test-support'; import log from '../lib/logger'; import B from 'bluebird'; diff --git a/packages/doctor/test/general-specs.js b/packages/doctor/test/general-specs.js index 74c91ec1f..0951fc1ab 100644 --- a/packages/doctor/test/general-specs.js +++ b/packages/doctor/test/general-specs.js @@ -7,7 +7,7 @@ import * as utils from '../lib/utils'; import NodeDetector from '../lib/node-detector'; import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import { withMocks } from 'appium-test-support'; +import { withMocks } from '@appium/test-support'; import B from 'bluebird'; import { removeColors } from './helper'; diff --git a/packages/doctor/test/ios-specs.js b/packages/doctor/test/ios-specs.js index 58d8265bc..d7787dafd 100644 --- a/packages/doctor/test/ios-specs.js +++ b/packages/doctor/test/ios-specs.js @@ -14,7 +14,7 @@ import log from '../lib/logger'; import chai from 'chai'; import chaiAsPromised from 'chai-as-promised'; import B from 'bluebird'; -import { withMocks, withSandbox, stubLog } from 'appium-test-support'; +import { withMocks, withSandbox, stubLog } from '@appium/test-support'; import {removeColors} from './helper'; chai.should(); @@ -28,12 +28,12 @@ describe('ios', function () { }); it('diagnose - success', async function () { // xcrun - mocks.tp.expects('exec').once().returns( - B.resolve({stdout: 'usage: simctl [--set ] [--profiles ] ...', stderr: ''})); + mocks.tp.expects('exec').once().resolves( + {stdout: 'usage: simctl [--set ] [--profiles ] ...', stderr: ''}); // xcode-select mocks.tp.expects('exec').once().returns( B.resolve({stdout: '/a/b/c/d\n', stderr: ''})); - mocks.fs.expects('exists').once().returns(B.resolve(true)); + mocks.fs.expects('exists').once().resolves(true); (await check.diagnose()).should.deep.equal({ ok: true, optional: false, @@ -46,7 +46,7 @@ describe('ios', function () { mocks.tp.expects('exec').once().returns( B.resolve({stdout: 'usage: simctl [--set ] [--profiles ] ...', stderr: ''})); // xcode-select - mocks.tp.expects('exec').once().returns(B.reject(new Error('Something wrong!'))); + mocks.tp.expects('exec').once().rejects(new Error('Something wrong!')); (await check.diagnose()).should.deep.equal({ ok: false, optional: false, @@ -61,7 +61,7 @@ describe('ios', function () { // xcode-select mocks.tp.expects('exec').once().returns( B.resolve({stdout: '/a/b/c/d\n', stderr: ''})); - mocks.fs.expects('exists').once().returns(B.resolve(false)); + mocks.fs.expects('exists').once().resolves(false); (await check.diagnose()).should.deep.equal({ ok: false, optional: false, @@ -71,7 +71,7 @@ describe('ios', function () { }); it('diagnose - failure - xcrun does not work', async function () { // xcrun - mocks.tp.expects('exec').once().returns(B.reject(new Error('xcrun: error: unable to find utility "simctl", not a developer tool or in PATH'))); + mocks.tp.expects('exec').once().rejects(new Error('xcrun: error: unable to find utility "simctl", not a developer tool or in PATH')); // no xcode-select (await check.diagnose()).should.deep.equal({ ok: false, @@ -121,7 +121,7 @@ describe('ios', function () { let logStub = stubLog(S.sandbox, log, {stripColors: true}); S.mocks.tp.expects('exec').once().returns( B.resolve({stdout: '', stderr: ''})); - S.mocks.prompter.expects('fixIt').once().returns(B.resolve('yes')); + S.mocks.prompter.expects('fixIt').once().resolves('yes'); await check.fix(); S.verify(); logStub.output.should.equal([ @@ -131,7 +131,7 @@ describe('ios', function () { it('fix - no', async function () { let logStub = stubLog(S.sandbox, log, {stripColors: true}); S.mocks.tp.expects('exec').never(); - S.mocks.prompter.expects('fixIt').once().returns(B.resolve('no')); + S.mocks.prompter.expects('fixIt').once().resolves('no'); await check.fix().should.be.rejectedWith(FixSkippedError); S.verify(); logStub.output.should.equal([ @@ -145,7 +145,7 @@ describe('ios', function () { it('fix - yes', async function () { let logStub = stubLog(S.sandbox, log, {stripColors: true}); S.mocks.utils.expects('authorizeIos').once(); - S.mocks.prompter.expects('fixIt').once().returns(B.resolve('yes')); + S.mocks.prompter.expects('fixIt').once().resolves('yes'); await fixes.authorizeIosFix(); S.verify(); logStub.output.should.equal([ @@ -155,7 +155,7 @@ describe('ios', function () { it('fix - no', async function () { let logStub = stubLog(S.sandbox, log, {stripColors: true}); S.mocks.utils.expects('authorizeIos').never(); - S.mocks.prompter.expects('fixIt').once().returns(B.resolve('no')); + S.mocks.prompter.expects('fixIt').once().resolves('no'); await fixes.authorizeIosFix().should.be.rejectedWith(FixSkippedError); S.verify(); logStub.output.should.equal([ @@ -180,7 +180,7 @@ describe('ios', function () { mocks.verify(); }); it('diagnose - failure - DevToolsSecurity crash', async function () { - mocks.tp.expects('exec').once().returns(B.reject(new Error('Something wrong!'))); + mocks.tp.expects('exec').once().rejects(new Error('Something wrong!')); (await check.diagnose()).should.deep.equal({ ok: false, optional: false, @@ -220,7 +220,7 @@ describe('ios', function () { mocks.verify(); }); it('diagnose - failure', async function () { - mocks.tp.expects('exec').once().returns(B.reject(new Error('Oh No!'))); + mocks.tp.expects('exec').once().rejects(new Error('Oh No!')); (await check.diagnose()).should.deep.equal({ ok: false, optional: false, @@ -240,7 +240,7 @@ describe('ios', function () { check.autofix.should.not.be.ok; }); it('diagnose - success', async function () { - mocks.CarthageDetector.expects('detect').once().returns(B.resolve('/usr/local/bin/carthage')); + mocks.CarthageDetector.expects('detect').once().resolves('/usr/local/bin/carthage'); mocks.tp.expects('exec').once().returns( B.resolve({stdout: 'Please update to the latest Carthage version: 0.33.0. You currently are on 0.32.0\n0.32.0\n', stderr: ''})); (await check.diagnose()).should.deep.equal({ @@ -251,7 +251,7 @@ describe('ios', function () { mocks.verify(); }); it('diagnose - success - one line carthage version', async function () { - mocks.CarthageDetector.expects('detect').once().returns(B.resolve('/usr/local/bin/carthage')); + mocks.CarthageDetector.expects('detect').once().resolves('/usr/local/bin/carthage'); mocks.tp.expects('exec').once().returns( B.resolve({stdout: '0.32.0\n', stderr: ''})); (await check.diagnose()).should.deep.equal({ @@ -262,7 +262,7 @@ describe('ios', function () { mocks.verify(); }); it('diagnose - success - but error happens', async function () { - mocks.CarthageDetector.expects('detect').once().returns(B.resolve('/usr/local/bin/carthage')); + mocks.CarthageDetector.expects('detect').once().resolves('/usr/local/bin/carthage'); mocks.tp.expects('exec').once().throws(new Error()); (await check.diagnose()).should.deep.equal({ ok: true, @@ -272,7 +272,7 @@ describe('ios', function () { mocks.verify(); }); it('diagnose - failure', async function () { - mocks.CarthageDetector.expects('detect').once().returns(B.resolve(null)); + mocks.CarthageDetector.expects('detect').once().resolves(null); (await check.diagnose()).should.deep.equal({ ok: false, optional: false, diff --git a/packages/doctor/test/node-detector-specs.js b/packages/doctor/test/node-detector-specs.js index 2a28fd5ba..9f9043072 100644 --- a/packages/doctor/test/node-detector-specs.js +++ b/packages/doctor/test/node-detector-specs.js @@ -5,7 +5,7 @@ import { fs, system } from 'appium-support'; import * as tp from 'teen_process'; import NodeDetector from '../lib/node-detector'; import B from 'bluebird'; -import { withSandbox } from 'appium-test-support'; +import { withSandbox } from '@appium/test-support'; import { EOL } from 'os'; diff --git a/packages/doctor/test/prompt-specs.js b/packages/doctor/test/prompt-specs.js index 0d869e909..c636177e5 100644 --- a/packages/doctor/test/prompt-specs.js +++ b/packages/doctor/test/prompt-specs.js @@ -3,7 +3,7 @@ import chai from 'chai'; import { fixIt, clear } from '../lib/prompt'; import { inquirer } from '../lib/utils'; -import { withMocks } from 'appium-test-support'; +import { withMocks } from '@appium/test-support'; import B from 'bluebird';