2015-05-23 18:11:42 +03:00
|
|
|
// transpile:mocha
|
|
|
|
|
|
|
|
import _ from 'lodash';
|
|
|
|
import chai from 'chai';
|
|
|
|
import sinon from 'sinon';
|
|
|
|
import chaiAsPromised from 'chai-as-promised';
|
2018-08-28 16:42:33 +03:00
|
|
|
import { getGitRev, getBuildInfo, checkNodeOk, warnNodeDeprecations,
|
2015-05-23 18:11:42 +03:00
|
|
|
getNonDefaultArgs, getDeprecatedArgs, validateServerArgs,
|
2018-08-28 16:42:33 +03:00
|
|
|
validateTmpDir, showConfig, checkValidPort, updateBuildInfo,
|
|
|
|
APPIUM_VER } from '../lib/config';
|
2015-05-23 18:11:42 +03:00
|
|
|
import getParser from '../lib/parser';
|
|
|
|
import logger from '../lib/logger';
|
2018-08-28 16:42:33 +03:00
|
|
|
import { fs } from 'appium-support';
|
|
|
|
import request from 'request-promise';
|
2015-05-23 18:11:42 +03:00
|
|
|
|
|
|
|
let should = chai.should();
|
|
|
|
chai.use(chaiAsPromised);
|
|
|
|
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('Config', function () {
|
|
|
|
describe('getGitRev', function () {
|
|
|
|
it('should get a reasonable git revision', async function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
let rev = await getGitRev();
|
|
|
|
rev.should.be.a('string');
|
|
|
|
rev.length.should.be.equal(40);
|
|
|
|
rev.match(/[0-9a-f]+/i)[0].should.eql(rev);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('Appium config', function () {
|
2018-08-28 16:42:33 +03:00
|
|
|
describe('getBuildInfo', function () {
|
|
|
|
async function verifyBuildInfoUpdate (useLocalGit) {
|
2018-10-03 16:39:25 +03:00
|
|
|
const buildInfo = getBuildInfo();
|
2018-08-28 16:42:33 +03:00
|
|
|
mockFs.expects('exists').atLeast(1).returns(useLocalGit);
|
|
|
|
buildInfo['git-sha'] = undefined;
|
|
|
|
buildInfo.built = undefined;
|
2018-10-10 19:41:33 +03:00
|
|
|
await updateBuildInfo(true);
|
2018-08-28 16:42:33 +03:00
|
|
|
buildInfo.should.be.an('object');
|
|
|
|
should.exist(buildInfo['git-sha']);
|
|
|
|
should.exist(buildInfo.built);
|
|
|
|
should.exist(buildInfo.version);
|
|
|
|
}
|
|
|
|
|
|
|
|
let mockFs;
|
|
|
|
let getStub;
|
|
|
|
beforeEach(function () {
|
|
|
|
mockFs = sinon.mock(fs);
|
|
|
|
getStub = sinon.stub(request, 'get');
|
|
|
|
});
|
|
|
|
afterEach(function () {
|
|
|
|
getStub.restore();
|
|
|
|
mockFs.restore();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should get a configuration object if the local git metadata is present', async function () {
|
|
|
|
await verifyBuildInfoUpdate(true);
|
|
|
|
});
|
|
|
|
it('should get a configuration object if the local git metadata is not present', async function () {
|
|
|
|
getStub.onCall(0).returns([
|
|
|
|
{
|
|
|
|
"name": `v${APPIUM_VER}`,
|
|
|
|
"zipball_url": "https://api.github.com/repos/appium/appium/zipball/v1.9.0-beta.1",
|
|
|
|
"tarball_url": "https://api.github.com/repos/appium/appium/tarball/v1.9.0-beta.1",
|
|
|
|
"commit": {
|
|
|
|
"sha": "3c2752f9f9c56000705a4ae15b3ba68a5d2e644c",
|
|
|
|
"url": "https://api.github.com/repos/appium/appium/commits/3c2752f9f9c56000705a4ae15b3ba68a5d2e644c"
|
|
|
|
},
|
|
|
|
"node_id": "MDM6UmVmNzUzMDU3MDp2MS45LjAtYmV0YS4x"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"name": "v1.8.2-beta",
|
|
|
|
"zipball_url": "https://api.github.com/repos/appium/appium/zipball/v1.8.2-beta",
|
|
|
|
"tarball_url": "https://api.github.com/repos/appium/appium/tarball/v1.8.2-beta",
|
|
|
|
"commit": {
|
|
|
|
"sha": "5b98b9197e75aa85e7507d21d3126c1a63d1ce8f",
|
|
|
|
"url": "https://api.github.com/repos/appium/appium/commits/5b98b9197e75aa85e7507d21d3126c1a63d1ce8f"
|
|
|
|
},
|
|
|
|
"node_id": "MDM6UmVmNzUzMDU3MDp2MS44LjItYmV0YQ=="
|
|
|
|
}
|
|
|
|
]);
|
|
|
|
getStub.onCall(1).returns({
|
|
|
|
"sha": "3c2752f9f9c56000705a4ae15b3ba68a5d2e644c",
|
|
|
|
"node_id": "MDY6Q29tbWl0NzUzMDU3MDozYzI3NTJmOWY5YzU2MDAwNzA1YTRhZTE1YjNiYTY4YTVkMmU2NDRj",
|
|
|
|
"commit": {
|
|
|
|
"author": {
|
|
|
|
"name": "Isaac Murchie",
|
|
|
|
"email": "isaac@saucelabs.com",
|
|
|
|
"date": "2018-08-17T19:48:00Z"
|
|
|
|
},
|
|
|
|
"committer": {
|
|
|
|
"name": "Isaac Murchie",
|
|
|
|
"email": "isaac@saucelabs.com",
|
|
|
|
"date": "2018-08-17T19:48:00Z"
|
|
|
|
},
|
|
|
|
"message": "v1.9.0-beta.1",
|
|
|
|
"tree": {
|
|
|
|
"sha": "2c0974727470eba419ea0b9951c52f72f8036b18",
|
|
|
|
"url": "https://api.github.com/repos/appium/appium/git/trees/2c0974727470eba419ea0b9951c52f72f8036b18"
|
|
|
|
},
|
|
|
|
"url": "https://api.github.com/repos/appium/appium/git/commits/3c2752f9f9c56000705a4ae15b3ba68a5d2e644c",
|
|
|
|
"comment_count": 0,
|
|
|
|
"verification": {
|
|
|
|
"verified": false,
|
|
|
|
"reason": "unsigned",
|
|
|
|
"signature": null,
|
|
|
|
"payload": null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"url": "https://api.github.com/repos/appium/appium/commits/3c2752f9f9c56000705a4ae15b3ba68a5d2e644c",
|
|
|
|
"html_url": "https://github.com/appium/appium/commit/3c2752f9f9c56000705a4ae15b3ba68a5d2e644c",
|
|
|
|
"comments_url": "https://api.github.com/repos/appium/appium/commits/3c2752f9f9c56000705a4ae15b3ba68a5d2e644c/comments",
|
|
|
|
});
|
|
|
|
await verifyBuildInfoUpdate(false);
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('showConfig', function () {
|
|
|
|
before(function () {
|
2015-12-02 22:33:36 +03:00
|
|
|
sinon.spy(console, "log");
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should log the config to console', async function () {
|
2018-10-03 16:39:25 +03:00
|
|
|
const config = getBuildInfo();
|
2015-05-23 18:11:42 +03:00
|
|
|
await showConfig();
|
2018-10-03 16:39:25 +03:00
|
|
|
console.log.calledOnce.should.be.true; // eslint-disable-line no-console
|
2016-08-03 22:14:29 +03:00
|
|
|
console.log.getCall(0).args[0].should.contain(JSON.stringify(config)); // eslint-disable-line no-console
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('node.js config', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
let _process = process;
|
2018-01-17 23:34:50 +03:00
|
|
|
before(function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
// need to be able to write to process.version
|
|
|
|
// but also to have access to process methods
|
|
|
|
// so copy them over to a writable object
|
|
|
|
let tempProcess = {};
|
2016-03-17 04:23:05 +03:00
|
|
|
for (let [prop, value] of _.toPairs(process)) {
|
2015-05-23 18:11:42 +03:00
|
|
|
tempProcess[prop] = value;
|
|
|
|
}
|
2018-10-03 16:39:25 +03:00
|
|
|
process = tempProcess; // eslint-disable-line no-global-assign
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
after(function () {
|
2018-10-03 16:39:25 +03:00
|
|
|
process = _process; // eslint-disable-line no-global-assign
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('checkNodeOk', function () {
|
2018-02-12 23:03:11 +03:00
|
|
|
it('should fail if node is below 6', function () {
|
2017-08-31 14:49:43 +03:00
|
|
|
process.version = 'v4.4.7';
|
|
|
|
checkNodeOk.should.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
process.version = 'v0.9.12';
|
2016-05-01 17:31:59 +03:00
|
|
|
checkNodeOk.should.throw();
|
|
|
|
process.version = 'v0.1';
|
|
|
|
checkNodeOk.should.throw();
|
|
|
|
process.version = 'v0.10.36';
|
|
|
|
checkNodeOk.should.throw();
|
2016-08-03 21:38:35 +03:00
|
|
|
process.version = 'v0.12.14';
|
|
|
|
checkNodeOk.should.throw();
|
|
|
|
process.version = 'v5.7.0';
|
2018-02-12 23:03:11 +03:00
|
|
|
checkNodeOk.should.throw();
|
2016-08-03 21:38:35 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should succeed if node is 6+', function () {
|
2016-08-03 21:38:35 +03:00
|
|
|
process.version = 'v6.3.1';
|
2016-05-01 17:31:59 +03:00
|
|
|
checkNodeOk.should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should succeed if node is 7+', function () {
|
2017-08-31 14:49:43 +03:00
|
|
|
process.version = 'v7.1.1';
|
|
|
|
checkNodeOk.should.not.throw();
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should succeed if node is 8+', function () {
|
2017-08-31 14:49:43 +03:00
|
|
|
process.version = 'v8.1.2';
|
|
|
|
checkNodeOk.should.not.throw();
|
|
|
|
});
|
2018-02-12 23:03:11 +03:00
|
|
|
it('should succeed if node is 9+', function () {
|
|
|
|
process.version = 'v9.1.2';
|
|
|
|
checkNodeOk.should.not.throw();
|
|
|
|
});
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('warnNodeDeprecations', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
let spy;
|
2018-01-17 23:34:50 +03:00
|
|
|
before(function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
spy = sinon.spy(logger, "warn");
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
beforeEach(function () {
|
2018-05-08 18:19:41 +03:00
|
|
|
spy.resetHistory();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-02-12 23:03:11 +03:00
|
|
|
it('should log a warning if node is below 8', function () {
|
|
|
|
process.version = 'v7.10.1';
|
2015-05-23 18:11:42 +03:00
|
|
|
warnNodeDeprecations();
|
|
|
|
logger.warn.callCount.should.equal(1);
|
|
|
|
});
|
2018-02-12 23:03:11 +03:00
|
|
|
it('should not log a warning if node is 8+', function () {
|
|
|
|
process.version = 'v8.0.0';
|
2016-08-03 21:38:35 +03:00
|
|
|
warnNodeDeprecations();
|
|
|
|
logger.warn.callCount.should.equal(0);
|
|
|
|
});
|
2018-02-12 23:03:11 +03:00
|
|
|
it('should not log a warning if node is 9+', function () {
|
|
|
|
process.version = 'v9.0.0';
|
2015-05-23 18:11:42 +03:00
|
|
|
warnNodeDeprecations();
|
|
|
|
logger.warn.callCount.should.equal(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('server arguments', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
let parser = getParser();
|
2016-05-01 17:31:59 +03:00
|
|
|
parser.debug = true; // throw instead of exit on error; pass as option instead?
|
2015-05-28 18:39:10 +03:00
|
|
|
let args = {};
|
2018-01-17 23:34:50 +03:00
|
|
|
beforeEach(function () {
|
2015-05-28 18:39:10 +03:00
|
|
|
// give all the defaults
|
|
|
|
for (let rawArg of parser.rawArgs) {
|
|
|
|
args[rawArg[1].dest] = rawArg[1].defaultValue;
|
|
|
|
}
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('getNonDefaultArgs', function () {
|
|
|
|
it('should show none if we have all the defaults', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
let nonDefaultArgs = getNonDefaultArgs(parser, args);
|
|
|
|
_.keys(nonDefaultArgs).length.should.equal(0);
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should catch a non-default argument', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
args.isolateSimDevice = true;
|
|
|
|
let nonDefaultArgs = getNonDefaultArgs(parser, args);
|
|
|
|
_.keys(nonDefaultArgs).length.should.equal(1);
|
|
|
|
should.exist(nonDefaultArgs.isolateSimDevice);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('getDeprecatedArgs', function () {
|
|
|
|
it('should show none if we have no deprecated arguments', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
let deprecatedArgs = getDeprecatedArgs(parser, args);
|
|
|
|
_.keys(deprecatedArgs).length.should.equal(0);
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should catch a deprecated argument', function () {
|
2015-06-03 20:41:21 +03:00
|
|
|
args.showIOSLog = true;
|
2015-05-23 18:11:42 +03:00
|
|
|
let deprecatedArgs = getDeprecatedArgs(parser, args);
|
|
|
|
_.keys(deprecatedArgs).length.should.equal(1);
|
2015-06-03 20:41:21 +03:00
|
|
|
should.exist(deprecatedArgs['--show-ios-log']);
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should catch a non-boolean deprecated argument', function () {
|
2015-05-28 18:39:10 +03:00
|
|
|
args.calendarFormat = 'orwellian';
|
|
|
|
let deprecatedArgs = getDeprecatedArgs(parser, args);
|
|
|
|
_.keys(deprecatedArgs).length.should.equal(1);
|
|
|
|
should.exist(deprecatedArgs['--calendar-format']);
|
|
|
|
});
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('checkValidPort', function () {
|
|
|
|
it('should be false for port too high', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
checkValidPort(65536).should.be.false;
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should be false for port too low', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
checkValidPort(0).should.be.false;
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should be true for port 1', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
checkValidPort(1).should.be.true;
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should be true for port 65535', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
checkValidPort(65535).should.be.true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('validateTmpDir', function () {
|
2018-10-03 16:39:25 +03:00
|
|
|
it('should fail to use a tmp dir with incorrect permissions', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
validateTmpDir('/private/if_you_run_with_sudo_this_wont_fail').should.be.rejectedWith(/could not ensure/);
|
|
|
|
});
|
2018-10-03 16:39:25 +03:00
|
|
|
it('should fail to use an undefined tmp dir', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
validateTmpDir().should.be.rejectedWith(/could not ensure/);
|
|
|
|
});
|
2018-10-03 16:39:25 +03:00
|
|
|
it('should be able to use a tmp dir with correct permissions', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
validateTmpDir('/tmp/test_tmp_dir/with/any/number/of/levels').should.not.be.rejected;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('parsing args with empty argv[1]', function () {
|
2017-02-10 21:38:04 +03:00
|
|
|
let argv1;
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
before(function () {
|
2017-02-10 21:38:04 +03:00
|
|
|
argv1 = process.argv[1];
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
after(function () {
|
2017-02-10 21:38:04 +03:00
|
|
|
process.argv[1] = argv1;
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should not fail if process.argv[1] is undefined', function () {
|
2017-02-10 21:38:04 +03:00
|
|
|
process.argv[1] = undefined;
|
|
|
|
let args = getParser();
|
|
|
|
args.prog.should.be.equal('Appium');
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should set "prog" to process.argv[1]', function () {
|
2017-02-10 21:38:04 +03:00
|
|
|
process.argv[1] = 'Hello World';
|
|
|
|
let args = getParser();
|
|
|
|
args.prog.should.be.equal('Hello World');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('validateServerArgs', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
let parser = getParser();
|
2016-05-01 17:31:59 +03:00
|
|
|
parser.debug = true; // throw instead of exit on error; pass as option instead?
|
|
|
|
const defaultArgs = {};
|
|
|
|
// give all the defaults
|
|
|
|
for (let rawArg of parser.rawArgs) {
|
|
|
|
defaultArgs[rawArg[1].dest] = rawArg[1].defaultValue;
|
|
|
|
}
|
|
|
|
let args = {};
|
2018-01-17 23:34:50 +03:00
|
|
|
beforeEach(function () {
|
2016-05-01 17:31:59 +03:00
|
|
|
args = _.clone(defaultArgs);
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('mutually exclusive server arguments', function () {
|
|
|
|
describe('noReset and fullReset', function () {
|
|
|
|
it('should not allow both', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.noReset = args.fullReset = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should allow noReset', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.noReset = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should allow fullReset', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.fullReset = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('ipa and safari', function () {
|
|
|
|
it('should not allow both', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.ipa = args.safari = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should allow ipa', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.ipa = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should allow safari', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.safari = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('app and safari', function () {
|
|
|
|
it('should not allow both', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.app = args.safari = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should allow app', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.app = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('forceIphone and forceIpad', function () {
|
|
|
|
it('should not allow both', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.forceIphone = args.forceIpad = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should allow forceIphone', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.forceIphone = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should allow forceIpad', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.forceIpad = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('deviceName and defaultDevice', function () {
|
|
|
|
it('should not allow both', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.deviceName = args.defaultDevice = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should allow deviceName', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.deviceName = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should allow defaultDevice', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
(() => {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.defaultDevice = true;
|
|
|
|
validateServerArgs(parser, args);
|
|
|
|
}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('validated arguments', function () {
|
2015-05-23 18:11:42 +03:00
|
|
|
// checking ports is already done.
|
|
|
|
// the only argument left is `backendRetries`
|
2018-01-17 23:34:50 +03:00
|
|
|
describe('backendRetries', function () {
|
|
|
|
it('should fail with value less than 0', function () {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.backendRetries = -1;
|
|
|
|
(() => {validateServerArgs(parser, args);}).should.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should succeed with value of 0', function () {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.backendRetries = 0;
|
|
|
|
(() => {validateServerArgs(parser, args);}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
2018-01-17 23:34:50 +03:00
|
|
|
it('should succeed with value above 0', function () {
|
2016-05-01 17:31:59 +03:00
|
|
|
args.backendRetries = 100;
|
|
|
|
(() => {validateServerArgs(parser, args);}).should.not.throw();
|
2015-05-23 18:11:42 +03:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|