fix: when parsing cap array, pass array through
MODIFY
lib/basedriver/helpers.js
lib/basedriver/helpers.js
@@ -354,6 +354,10 @@ function duplicateKeys (input, firstKey, secondKey) {
* @param {string|Array<String>} cap A desired capability
*/
function parseCapsArray (cap) {
+ if (_.isArray(cap)) {
+ return cap;
+ }
+
let parsedCaps;
try {
parsedCaps = JSON.parse(cap);

MODIFY
test/basedriver/helpers-specs.js
test/basedriver/helpers-specs.js
@@ -98,11 +98,14 @@ describe('parseCapsArray', function () {
it('should parse string into array', function () {
parseCapsArray('/tmp/my/app.zip').should.eql(['/tmp/my/app.zip']);
});
- it('should parse array into array', function () {
+ it('should parse array as string into array', function () {
parseCapsArray('["/tmp/my/app.zip"]').should.eql(['/tmp/my/app.zip']);
parseCapsArray('["/tmp/my/app.zip","/tmp/my/app2.zip"]').should.eql([
'/tmp/my/app.zip',
'/tmp/my/app2.zip'
]);
});
+ it('should return an array without change', function () {
+ parseCapsArray(['a', 'b']).should.eql(['a', 'b']);
+ });
});

MODIFY
test/jsonwp-proxy/protocol-converter-specs.js
test/jsonwp-proxy/protocol-converter-specs.js
-// transpile:mocha
-/* global describe:true, it:true */
-
import _ from 'lodash';
import { PROTOCOLS } from '../../lib/protocol';
import ProtocolConverter, {COMMAND_URLS_CONFLICTS} from '../../lib/jsonwp-proxy/protocol-converter';

MODIFY
test/jsonwp-proxy/proxy-specs.js
test/jsonwp-proxy/proxy-specs.js
// transpile:mocha
-/* global describe:true, it:true */
import { JWProxy } from '../..';
import request from './mock-request';

MODIFY
test/jsonwp-proxy/url-specs.js
test/jsonwp-proxy/url-specs.js
// transpile:mocha
-/* global describe:true, it:true */
import { JWProxy } from '../..';
import chai from 'chai';

MODIFY
test/jsonwp-status/status-specs.js
test/jsonwp-status/status-specs.js
-// transpile:mocha
-/* global describe:true, it:true */
-
import _ from 'lodash';
import { statusCodes, getSummaryByCode } from '../..';
import chai from 'chai';

fix: when parsing cap array, pass array through (#373)