Skip to content

Commit

Permalink
fix eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann committed Apr 11, 2017
1 parent bad7d32 commit 05cbd31
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/commands/chooseFile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ let chooseFile = function (selector, localPath) {
}

return new Promise((resolve, reject) => {
fs.exists(localPath, (exists) => {
fs.stat(localPath, (err) => {
/* istanbul ignore next */
if (!exists) {
if (err) {
return reject(new CommandError('File to upload does not exists on your system'))
}

Expand Down
1 change: 1 addition & 0 deletions lib/commands/saveScreenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
*/

import fs from 'fs'
import { Buffer } from 'safe-buffer'

let saveScreenshot = function (filename) {
return this.screenshot().then((res) => {
Expand Down
4 changes: 2 additions & 2 deletions lib/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Runner {
this.initialiseServices(config)

config.beforeSession.forEach(
async (hook) => await hook(config, this.caps, this.specs)
async (hook) => hook(config, this.caps, this.specs)
)

this.framework = this.initialiseFramework(config)
Expand Down Expand Up @@ -183,7 +183,7 @@ class Runner {
await this.end(this.failures)

config.afterSession.forEach(
async (hook) => await hook(config, this.caps, this.specs)
async (hook) => hook(config, this.caps, this.specs)
)
process.exit(this.failures === 0 ? 0 : 1)
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion lib/scripts/createSelectorScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ var executeClientSide = function (fn, sArr, args) {
sArgs.push(arg)
}

var parameter = args && sArgs.concat(args) || sArgs
var parameter = (args && sArgs.concat(args)) || sArgs
if (parameter.length === 0 || (parameter.length === 1 && parameter[0].length === 0)) {
if (typeof cb === 'function') {
return cb('NoSuchElement') && new Error('NoSuchElement')
Expand Down
25 changes: 24 additions & 1 deletion lib/scripts/eventSimulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,30 @@ let eventSimulator = function () {
break
}

document.createEvent ? (b = document.createEvent(a), a === 'HTMLEvents' ? b.initEvent(c, !0, !0) : b.initMouseEvent(c, !0, !0, document.defaultView, 0, xto, yto, xto, yto, !1, !1, !1, !1, btnCode, null), f.dispatchEvent(b)) : (a = document.createEventObject(), a.detail = 0, a.screenX = xto, a.screenY = yto, a.clientX = xto, a.clientY = yto, a.ctrlKey = !1, a.altKey = !1, a.shiftKey = !1, a.metaKey = !1, a.button = 1, f.fireEvent('on' + c, a))
if (document.createEvent) {
b = document.createEvent(a)

if (a === 'HTMLEvents') {
b.initEvent(c, !0, !0)
} else {
b.initMouseEvent(c, !0, !0, document.defaultView, 0, xto, yto, xto, yto, !1, !1, !1, !1, btnCode, null)
}

f.dispatchEvent(b)
} else {
a = document.createEventObject()
a.detail = 0
a.screenX = xto
a.screenY = yto
a.clientX = xto
a.clientY = yto
a.ctrlKey = !1
a.altKey = !1
a.shiftKey = !1
a.metaKey = !1
a.button = 1
f.fireEvent('on' + c, a)
}
return true
}
var eventMatchers = {
Expand Down
3 changes: 2 additions & 1 deletion lib/webdriverio.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from 'path'
import merge from 'deepmerge'
import mkdirp from 'mkdirp'
import events from 'events'
import { Buffer } from 'safe-buffer'

import RequestHandler from './utils/RequestHandler'
import { RuntimeError } from './utils/ErrorHandler'
Expand Down Expand Up @@ -272,7 +273,7 @@ let WebdriverIO = function (args, modifier) {
e = new Error(e)
}

const message = e.seleniumStack && e.seleniumStack.message || e.message
const message = (e.seleniumStack && e.seleniumStack.message) || e.message

let stack = stacktrace.slice().map(trace => ' at ' + trace)
e.stack = e.name + ': ' + message + '\n' + stack.reverse().join('\n')
Expand Down
2 changes: 2 additions & 0 deletions test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
"chai-expect"
],
"rules": {
"no-unused-expressions": 0,

"mocha/no-exclusive-tests": [2],
"mocha/no-pending-tests": [2],
"mocha/handle-done-callback": [2],
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/custom.commands.wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const CUSTOM_COMMANDS = {
return new Promise(function (resolve, reject) {
self.elements(selector).then(function (res) {
if (!res || res.status === -1) {
reject()
return reject(new Error('no element found'))
}
resolve(res.value.length)
})
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/specs/waitUntil.async.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('waitUntil async', () => {

it('should allow to define own error message', () => {
const errorMsg = 'my own error message'
return browser.waitUntil(() => Promise.reject(), 100, errorMsg).catch((e) => {
return browser.waitUntil(() => Promise.reject(new Error('buu')), 100, errorMsg).catch((e) => {
expect(e.message).to.be.equal(errorMsg)

/**
Expand Down
4 changes: 2 additions & 2 deletions test/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ before(async function () {
await this.client.init()
})

beforeEach(async function() {
beforeEach(async function () {
if (process.env._ENV && process.env._ENV.match(/(android|ios)/)) {
return
}
Expand All @@ -54,7 +54,7 @@ beforeEach(async function() {

after(async function () {
const sessionId = this.client.requestHandler.sessionID
await this.client[process.env._ENV && process.env._ENV.match(/(multibrowser|android)/) || process.env.CI ? 'end' : 'endAll']()
await this.client[(process.env._ENV && process.env._ENV.match(/(multibrowser|android)/)) || process.env.CI ? 'end' : 'endAll']()

/**
* if we are not running on travis we are done here
Expand Down
2 changes: 1 addition & 1 deletion test/spec/unit/timer.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('timer', () => {
})

it('should be rejected', () => {
let timer = new Timer(20, 30, () => Promise.reject('err'))
let timer = new Timer(20, 30, () => Promise.reject(new Error('err')))

return timer.then(assert.fail).catch((msg) => {
expect(msg).to.be.equal('err')
Expand Down
7 changes: 6 additions & 1 deletion test/spec/unit/waitUntil.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ describe('waitUntil', () => {
it('should get rejected', async function () {
let error
try {
await this.client.waitUntil(() => new Promise((resolve, reject) => setTimeout(() => reject('foobar'), 500)), 1000)
await this.client.waitUntil(() =>
new Promise((resolve, reject) =>
setTimeout(
() => reject(new Error('foobar')),
500)
), 1000)
} catch (e) {
error = e
} finally {
Expand Down

0 comments on commit 05cbd31

Please sign in to comment.