diff --git a/config/index.js b/config/index.js index 6410bc44..e755ba0d 100644 --- a/config/index.js +++ b/config/index.js @@ -11,7 +11,7 @@ const timestamp = require('../lib/constants/timestamp'); const {validate, validators} = require('../lib/validation'); const {invalidConfigObj} = require('../lib/texts'); const {pickNonNil} = require('../lib/utils/common'); -const envVars = require('../lib/constants/enviroment'); +const envVars = require('../lib/constants/environment'); const sentryDsn = 'https://1f74b885d0c44549b57f307733d60351:dd736ff3ac994104ab6635da53d9be2e@sentry.io/288812'; const DEFAULT_TIMEOUT = 2000; diff --git a/lib/composers/acceptModalComposer.js b/lib/composers/acceptModalComposer.js index ad81e6f5..b2429113 100644 --- a/lib/composers/acceptModalComposer.js +++ b/lib/composers/acceptModalComposer.js @@ -8,14 +8,17 @@ const {invalidInputMessage} = require('../texts'); * Accept modal dialog, optionally sending message * @param {String} [message] - text to be send to modal dialog */ -const acceptModalComposer = makeModifierComposer(composers.ACCEPT_MODAL, ['acceptModal'], (_, meta, message = null) => ({ - ...meta, - isAcceptModal: true, - acceptModalMessage: validate( - validators.NON_EMPTY_STRING_OR_NUll, - message, - invalidInputMessage('acceptModal', 'Message value'), - ), -})); +const acceptModalComposer = makeModifierComposer( + composers.ACCEPT_MODAL, + ['acceptModal'], + (_, meta, message = null) => ({ + ...meta, + isAcceptModal: true, + acceptModalMessage: validate( + validators.NON_EMPTY_STRING_OR_NUll, + message, + invalidInputMessage('acceptModal', 'Message value'), + ), + })); module.exports = acceptModalComposer; diff --git a/lib/composers/cloneComposer.js b/lib/composers/cloneComposer.js index 3e58d37c..8fe2adf2 100644 --- a/lib/composers/cloneComposer.js +++ b/lib/composers/cloneComposer.js @@ -8,7 +8,7 @@ const cloneComposer = makeModifierComposer( composers.CLONE, ['clone'], (_, meta) => ({...meta}), - {unregisterParent: false} + {unregisterParent: false}, ); module.exports = cloneComposer; diff --git a/lib/composers/matchBrightScriptComposer.js b/lib/composers/matchBrightScriptComposer.js index 04184ce3..db9eb165 100644 --- a/lib/composers/matchBrightScriptComposer.js +++ b/lib/composers/matchBrightScriptComposer.js @@ -22,7 +22,7 @@ const matchBrightScriptComposer = makeModifierComposer( val: res, }, }; - } + }, ); module.exports = matchBrightScriptComposer; diff --git a/lib/composers/matchRepoComposer.js b/lib/composers/matchRepoComposer.js index ff5a4a77..a41a0239 100644 --- a/lib/composers/matchRepoComposer.js +++ b/lib/composers/matchRepoComposer.js @@ -38,16 +38,19 @@ const processMatchRepoArgs = makeArgumentsProcessor( }), ); -const matchRepoComposer = makeModifierComposer(composers.MATCH_REPO, ['matchRepo', 'matchesRepo'], (_, data, ...args) => ({ - ...data, - comparator: { - type: SUBJ_COMPARATOR.MATCH, - props: validation.validate( - validation.validators.ELEMENT_REPO_PROPS, - processMatchRepoArgs(args), - invalidInputMessage('matchRepo', 'Property') - ), - }, -})); +const matchRepoComposer = makeModifierComposer( + composers.MATCH_REPO, + ['matchRepo', 'matchesRepo'], + (_, data, ...args) => ({ + ...data, + comparator: { + type: SUBJ_COMPARATOR.MATCH, + props: validation.validate( + validation.validators.ELEMENT_REPO_PROPS, + processMatchRepoArgs(args), + invalidInputMessage('matchRepo', 'Property'), + ), + }, + })); module.exports = matchRepoComposer; diff --git a/lib/composers/requestMatchesComposer.js b/lib/composers/requestMatchesComposer.js index 63fbd440..0f6b9812 100644 --- a/lib/composers/requestMatchesComposer.js +++ b/lib/composers/requestMatchesComposer.js @@ -31,7 +31,7 @@ const processRequestArgs = makeArgumentsProcessor( */ ({name, val, type = PROP_COMPARATOR.EQUAL}) => getRequestMatchItem(name, val, type), objArg => 'name' in objArg && 'val' in objArg, - getRequestMatchItem + getRequestMatchItem, ); const requestMatchesComposer = makeModifierComposer( @@ -47,7 +47,7 @@ const requestMatchesComposer = makeModifierComposer( invalidInputMessage('requestMatch', 'Header'), ), }, - }) + }), ); module.exports = requestMatchesComposer; diff --git a/lib/composers/responseMatchesComposer.js b/lib/composers/responseMatchesComposer.js index ccd9a60b..7421a499 100644 --- a/lib/composers/responseMatchesComposer.js +++ b/lib/composers/responseMatchesComposer.js @@ -32,7 +32,7 @@ const processResponseArgs = makeArgumentsProcessor( */ ({name, val, type = PROP_COMPARATOR.EQUAL}) => getResponseMatchComposers(name, val, type), objArg => 'name' in objArg && 'val' in objArg, - getResponseMatchComposers + getResponseMatchComposers, ); const responseMatchesComposer = makeModifierComposer( @@ -45,10 +45,10 @@ const responseMatchesComposer = makeModifierComposer( props: validation.validate( validation.validators.RESPONSE_MATCHES, processResponseArgs(args), - invalidInputMessage('responseMatch', 'Header') + invalidInputMessage('responseMatch', 'Header'), ), }, - }) + }), ); module.exports = responseMatchesComposer; diff --git a/lib/composers/swipeComposer.js b/lib/composers/swipeComposer.js index dd53fbd5..2871a672 100644 --- a/lib/composers/swipeComposer.js +++ b/lib/composers/swipeComposer.js @@ -6,12 +6,21 @@ const {invalidInputMessage} = require('../texts'); /** * Defines click method */ -const swipeComposer = makeModifierComposer(composers.TAP, ['swipe', 'flick'], (_, meta, direction, distance, duration) => ({ - ...meta, - isSwipe: true, - direction: validate(validators.DIRECTIONS, direction, invalidInputMessage('swipe/flick', 'direction')), - distance: validate(validators.ST_VAR_OR_POSITIVE_NUMBER, distance, invalidInputMessage('swipe/flick', 'distance')), - duration: validate(validators.ST_VAR_OR_POSITIVE_NUMBER, duration, invalidInputMessage('swipe/flick', 'duration')), -})); +const swipeComposer = makeModifierComposer( + composers.TAP, + ['swipe', 'flick'], + (_, meta, direction, distance, duration) => ({ + ...meta, + isSwipe: true, + direction: validate(validators.DIRECTIONS, direction, invalidInputMessage('swipe/flick', 'direction')), + distance: validate( + validators.ST_VAR_OR_POSITIVE_NUMBER, distance, + invalidInputMessage('swipe/flick', 'distance'), + ), + duration: validate( + validators.ST_VAR_OR_POSITIVE_NUMBER, duration, + invalidInputMessage('swipe/flick', 'duration'), + ), + })); module.exports = swipeComposer; diff --git a/lib/constants/enviroment.js b/lib/constants/environment.js similarity index 77% rename from lib/constants/enviroment.js rename to lib/constants/environment.js index e6eec53d..7aec2708 100644 --- a/lib/constants/enviroment.js +++ b/lib/constants/environment.js @@ -1,4 +1,4 @@ -const ENVIROMENT_VARS = Object.freeze({ +const ENVIRONMENT_VARS = Object.freeze({ /** * @description indicates that session is running as launcher child process, contains deviceId|configId|ipcPortNumber */ @@ -7,4 +7,4 @@ const ENVIROMENT_VARS = Object.freeze({ SUITEST_BE_SERVER: 'SUITEST_BE_SERVER', }); -module.exports = ENVIROMENT_VARS; +module.exports = ENVIRONMENT_VARS; diff --git a/lib/constants/screenOrientation.js b/lib/constants/screenOrientation.js index a75bc598..e33e5479 100644 --- a/lib/constants/screenOrientation.js +++ b/lib/constants/screenOrientation.js @@ -1,3 +1,5 @@ +/* eslint-disable key-spacing */ + const screenOrientation = { PORTRAIT: 'portrait', PORTRAIT_REVERSED: 'portraitReversed', diff --git a/lib/testLauncher/repl.js b/lib/testLauncher/repl.js index ef3c8f0b..b0d2795d 100644 --- a/lib/testLauncher/repl.js +++ b/lib/testLauncher/repl.js @@ -6,7 +6,7 @@ const chokidar = require('chokidar'); const texts = require('../texts'); const ipcClient = require('./ipc/client'); -const envVars = require('../constants/enviroment'); +const envVars = require('../constants/environment'); const messageId = require('../constants/ipcMessageId'); const errorListeners = require('../utils/errorListeners'); const {getShortFunctionBody} = require('../utils/stringUtils'); diff --git a/lib/utils/AuthContext.js b/lib/utils/AuthContext.js index 1db20e27..2504d949 100644 --- a/lib/utils/AuthContext.js +++ b/lib/utils/AuthContext.js @@ -56,7 +56,7 @@ const allowedRequests = { * Decorate http requestObject with current context headers * @param {*} requestObject * @param {*} headers - * @returns requestObject decoerated with auth headers + * @returns requestObject decorated with auth headers */ function decorateRequestObject(requestObject, headers) { return Object.assign({}, requestObject, {headers}); diff --git a/lib/utils/sessionStarter.js b/lib/utils/sessionStarter.js index 259f5c0b..04d35798 100644 --- a/lib/utils/sessionStarter.js +++ b/lib/utils/sessionStarter.js @@ -2,7 +2,7 @@ const {TOKEN} = require('../constants/modes'); const chainPromise = require('./chainPromise'); const {validate, validators} = require('../validation'); const {captureException} = require('./sentry/Raven'); -const envVars = require('../constants/enviroment'); +const envVars = require('../constants/environment'); const messageId = require('../constants/ipcMessageId'); const ipcClient = require('../testLauncher/ipc/client'); const {replWarn} = require('../texts'); diff --git a/lib/utils/testLauncherHelper.js b/lib/utils/testLauncherHelper.js index fbb7ae51..261dd214 100644 --- a/lib/utils/testLauncherHelper.js +++ b/lib/utils/testLauncherHelper.js @@ -11,7 +11,7 @@ const texts = require('../texts'); const Queue = require('./Queue'); const {registerProcess} = require('../testLauncher/processReaper'); -const envVars = require('../constants/enviroment'); +const envVars = require('../constants/environment'); const {version} = require('../../package.json'); const {stripAnsiChars} = require('./stringUtils'); @@ -192,7 +192,7 @@ function logOutput(child, chunk, logStream) { * needs to be called to enable sending terminal codes. * When repl ends the node process for some reason does not want to take over * the ownership of the terminal anymore (setRawMode(false) does not help). - * This function manually enables ctrl+c togther with the keypress module + * This function manually enables ctrl+c together with the keypress module * @param {string} ch * @param {Object} key */ diff --git a/lib/validation/jsonSchemas.js b/lib/validation/jsonSchemas.js index 99e66406..5adf7f82 100644 --- a/lib/validation/jsonSchemas.js +++ b/lib/validation/jsonSchemas.js @@ -147,7 +147,7 @@ const deviation = { 'then': {'type': ['number', 'string']}, 'else': {'const': 'undefined'}, }; -const propComarator = { +const propComparator = { 'type': 'string', 'enum': Object.values(PROP_COMPARATOR), }; @@ -164,7 +164,7 @@ schemas[validationKeys.ELEMENT_PROPS] = { 'type': 'string', 'enum': Object.values(ELEMENT_PROP), }, - 'type': propComarator, + 'type': propComparator, 'val': {'const': VALUE.REPO}, deviation, }}, @@ -173,7 +173,7 @@ schemas[validationKeys.ELEMENT_PROPS] = { 'type': 'string', 'enum': ELEMENT_PROP_BY_TYPE.integer, }, - 'type': propComarator, + 'type': propComparator, 'val': {'type': ['integer', 'string']}, deviation, }}, @@ -182,55 +182,55 @@ schemas[validationKeys.ELEMENT_PROPS] = { 'type': 'string', 'enum': ELEMENT_PROP_BY_TYPE.string, }, - 'type': propComarator, + 'type': propComparator, 'val': {'type': 'string'}, deviation, }}, {'properties': { 'name': {'enum': ELEMENT_PROP_BY_TYPE.number}, - 'type': propComarator, + 'type': propComparator, 'val': {'type': ['number', 'string']}, deviation, }}, {'properties': { 'name': {'enum': ELEMENT_PROP_BY_TYPE.boolean}, - 'type': propComarator, + 'type': propComparator, 'val': {'type': 'boolean'}, deviation, }}, {'properties': { 'name': {'const': ELEMENT_PROP.BORDER_STYLE}, - 'type': propComarator, + 'type': propComparator, 'val': {'enum': Object.values(BORDER_STYLE)}, }}, {'properties': { 'name': {'const': ELEMENT_PROP.VIDEO_STATE}, - 'type': propComarator, + 'type': propComparator, 'val': {'enum': Object.values(VIDEO_STATE)}, }}, {'properties': { 'name': {'const': ELEMENT_PROP.VISIBILITY}, - 'type': propComarator, + 'type': propComparator, 'val': {'enum': [VISIBILITY_STATE.COLLAPSED, VISIBILITY_STATE.INVISIBLE, VISIBILITY_STATE.VISIBLE]}, }}, {'properties': { 'name': {'const': ELEMENT_PROP.CONTENT_MODE}, - 'type': propComarator, + 'type': propComparator, 'val': {'enum': Object.values(CONTENT_MODE)}, }}, {'properties': { 'name': {'const': ELEMENT_PROP.STATE}, - 'type': propComarator, + 'type': propComparator, 'val': {'enum': Object.values(ELEMENT_STATE)}, }}, {'properties': { 'name': {'const': ELEMENT_PROP.TEXT_ALIGNMENT}, - 'type': propComarator, + 'type': propComparator, 'val': {'enum': Object.values(TEXT_ALIGNMENT)}, }}, {'properties': { 'name': {'const': ELEMENT_PROP.IMAGE_LOAD_STATE}, - 'type': propComarator, + 'type': propComparator, 'val': {'enum': Object.values(IMAGE_LOAD_STATE)}, }}, ], @@ -245,7 +245,7 @@ schemas[validationKeys.ELEMENT_REPO_PROPS] = { 'additionalProperties': false, 'properties': { 'name': {'enum': Object.values(ELEMENT_PROP)}, - 'type': propComarator, + 'type': propComparator, 'val': {'const': VALUE.REPO}, deviation, }, @@ -261,17 +261,17 @@ schemas[validationKeys.REQUEST_MATCHES] = { {'properties': { 'name': {'type': 'string'}, 'val': {'type': 'string'}, - 'compare': propComarator, + 'compare': propComparator, }}, {'properties': { 'name': {'const': NETWORK_PROP.METHOD}, 'val': {'enum': Object.values(NETWORK_METHOD)}, - 'compare': propComarator, + 'compare': propComparator, }}, {'properties': { 'name': {'const': NETWORK_PROP.BODY}, 'val': {'type': 'string'}, - 'compare': propComarator, + 'compare': propComparator, }}, ], }, @@ -286,17 +286,17 @@ schemas[validationKeys.RESPONSE_MATCHES] = { {'properties': { 'name': {'type': 'string'}, 'val': {'type': 'string'}, - 'compare': propComarator, + 'compare': propComparator, }}, {'properties': { 'name': {'const': NETWORK_PROP.STATUS}, 'val': {'type': ['number', 'string']}, - 'compare': propComarator, + 'compare': propComparator, }}, {'properties': { 'name': {'const': NETWORK_PROP.BODY}, 'val': {'type': 'string'}, - 'compare': propComarator, + 'compare': propComparator, }}, ], }, diff --git a/lib/validation/validators.js b/lib/validation/validators.js index d8c4ca6e..59adc30a 100644 --- a/lib/validation/validators.js +++ b/lib/validation/validators.js @@ -28,8 +28,6 @@ function throwError(text) { ); } -const getElementPropName = (mapOfNames, name) => typeof mapOfNames[name] === 'string' ? mapOfNames[name] : name; - /** * @description returns prettified errors messages for element properties errors * @param {Object} validate @@ -130,7 +128,7 @@ function prettifyJsonSchemaErrors(validate) { * @param {*|Symbol} schemaKey json schema of schemas map key * @param {*} data * @param {String} errorMessage - * @returns {*} input data or thorws error + * @returns {*} input data or throws error * @throws SuitestError */ function validateJsonSchema(schemaKey, data, errorMessage) { diff --git a/test/testLauncher/repl.test.js b/test/testLauncher/repl.test.js index 5055b445..cbb65f61 100644 --- a/test/testLauncher/repl.test.js +++ b/test/testLauncher/repl.test.js @@ -5,7 +5,7 @@ const chokidar = require('chokidar'); const EventEmitter = require('events'); const logger = require('../../index').logger; -const envVars = require('../../lib/constants/enviroment'); +const envVars = require('../../lib/constants/environment'); const suitestRepl = require('../../lib/testLauncher/repl'); const ipcClient = require('../../lib/testLauncher/ipc/client'); @@ -60,11 +60,11 @@ describe('repl', () => { process.env[envVars.SUITEST_CHILD_PROCESS] = 'test'; - const replPromsie = suitestRepl.startRepl({}); + const replPromise = suitestRepl.startRepl({}); assert.ok(writeStub.calledOnce); assert.ok(addListenerStub.calledOnce); - assert.ok(replPromsie instanceof Promise); + assert.ok(replPromise instanceof Promise); delete process.env[envVars.SUITEST_CHILD_PROCESS]; }); @@ -73,11 +73,11 @@ describe('repl', () => { sandbox.stub(process, 'chdir'); const writeStub = sandbox.stub(ipcClient, 'write'); const addListenerStub = sandbox.stub(ipcClient, 'addListener'); - const replPromsie = suitestRepl.startRepl({}); + const replPromise = suitestRepl.startRepl({}); assert.ok(writeStub.notCalled); assert.ok(addListenerStub.notCalled); - assert.ok(replPromsie instanceof Promise); + assert.ok(replPromise instanceof Promise); }); it('stopRepl', () => { @@ -150,7 +150,7 @@ describe('repl', () => { repeaterFromString( 'repl#repeater', path.join(__dirname, '/../../lib/utils/testHelpers/'), - '' + '', )(); assert(repeater.called, 'Repeater with module spec was correctly resolved'); @@ -163,7 +163,7 @@ describe('repl', () => { repeaterFromString( 'repl#nested.repeater', path.join(__dirname, '/../../lib/utils/testHelpers/'), - '' + '', )(); assert(repeater.called, 'Nested repeater with module spec was correctly resolved'); @@ -171,7 +171,7 @@ describe('repl', () => { repeaterFromString( 'nested.repeater', path.join(__dirname, '/../../lib/utils/testHelpers/'), - 'repl.js' + 'repl.js', )(); assert(repeater.secondCall, 'Repeater without module name was correctly resolved');