Skip to content

Commit

Permalink
use eslint package of standradjs
Browse files Browse the repository at this point in the history
  • Loading branch information
simonseyock committed Jul 12, 2018
1 parent 1b8be68 commit aee8fe4
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": ["standard"],
"rules": {
"max-len": ["error", 120],
"no-console": "error"
"no-console": "error",
"import/no-webpack-loader-syntax": "off"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"concurrently": "^3.6.0",
"esdoc": "^1.1.0",
"esdoc-standard-plugin": "^1.0.0",
"eslint": "^5.1.0",
"guide4you-builder": "3.2.1",
"guide4you-proxy": "github:KlausBenndorf/guide4you-proxy#v1.1.0",
"http-server": "^0.11.1",
Expand All @@ -45,7 +46,7 @@
"openlayers": "github:KlausBenndorf/ol3#g4u3_v5.0.2",
"phantomjs-prebuilt": "2.1.14",
"selenium-webdriver": "3.6.0",
"standard": "^11.0.1",
"eslint-config-standard": "^11.0.0",
"wait-on": "^2.1.0"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/API.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export class API extends ol.Object {
}
let loadErrorHandler = () => {
source.un('vectorloaderror', loadEndHandler)
reject('vector load error')
reject(new Error('vector load error'))
}
source.once('vectorloadend', loadEndHandler)
source.once('vectorloaderror', loadErrorHandler)
Expand Down
8 changes: 4 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import '../images/g4u-logo.png'

import 'polyfill!requestAnimationFrame,cancelAnimationFrame,Element.prototype.classList,URL'

window.jQuery = window.jQuery || $

import {G4UMap} from './G4UMap'
import {Debug} from './Debug'

window.jQuery = window.jQuery || $

export function createMapInternal (element, clientConfPath, layerConfPath, options) {
if (Array.isArray(options)) { // backwards compatibility
options = { modules: options }
Expand All @@ -18,7 +18,7 @@ export function createMapInternal (element, clientConfPath, layerConfPath, optio
return new Promise((resolve, reject) => {
$(document).ready(() => {
if (!$) {
reject('jQuery not available.')
reject(new Error('jQuery not available.'))
} else {
let v = $().jquery.split('.')
if (+v[0] < 2 && +v[1] < 9) {
Expand All @@ -27,7 +27,7 @@ export function createMapInternal (element, clientConfPath, layerConfPath, optio
}

if (!ol) {
reject('OpenLayers not available.')
reject(new Error('OpenLayers not available.'))
}

$(element).empty()
Expand Down
2 changes: 1 addition & 1 deletion src/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function asyncImageLoad (image, origUrl, finalUrl) {
}
return new Promise((resolve, reject) => {
function onError () {
reject(`Error loading url ${finalUrl}`)
reject(new Error(`Error loading url ${finalUrl}`))
}
image.addEventListener('load', resolve)
image.addEventListener('error', onError)
Expand Down
18 changes: 7 additions & 11 deletions tests/layerSelector_spec.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import webdriver from 'selenium-webdriver'
import {By, until} from 'selenium-webdriver'
import phantomDriver from './customPhantomDriver'
import test from 'selenium-webdriver/testing/'
import {describe, before, after, it} from 'selenium-webdriver/testing/'
import assert from 'selenium-webdriver/testing/assert.js'
import config from './config.js'
import until from 'selenium-webdriver/lib/until'

let By = webdriver.By

import {executeFunctionInPage, waitUntilMapReady} from './testUtils'

// globals in browser
Expand All @@ -24,22 +20,22 @@ function waitUntilSetFeatureLayers (driver, featureLayers) {
.then(waitUntilMapReady(driver))
}

test.describe('LayerSelector', function () {
describe('LayerSelector', function () {
this.timeout(config.mochaTimeout)
let driver

test.before(function () {
before(function () {
driver = phantomDriver()
driver.manage().window().setSize(1200, 800)
driver.manage().timeouts().implicitlyWait(config.seleniumTimeout)
driver.manage().timeouts().pageLoadTimeout(config.seleniumTimeout)
})

test.after(function () {
after(function () {
driver.quit()
})

test.it('should show a layerSelector', function (done) {
it('should show a layerSelector', function (done) {
driver.get(config.testClient).then(
waitUntilMapReady(driver)
).then(
Expand All @@ -62,7 +58,7 @@ test.describe('LayerSelector', function () {
)
})

test.it('should show a category button', function (done) {
it('should show a category button', function (done) {
driver.get(config.testClient).then(
waitUntilMapReady(driver)
).then(
Expand Down
20 changes: 7 additions & 13 deletions tests/testUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ export function waitUntilMapReady (driver) {
driver.executeAsyncScript(function (callback) {
setTimeout(function () {
if (window.test) {
callback('READY')
callback(null)
}
if (!window.map) {
callback('NOEXIST')
callback(new Error('Map does not exist after 20 ms'))
}
const t = setTimeout(function () {
callback('NOREADY')
callback(new Error('Map not ready after 2000 ms'))
}, 2000)
window.map.asSoonAs('ready', true, function () {
clearTimeout(t)
callback('READY')
callback(null)
})
}, 20)
}).then(function (val) {
if (val === 'READY') {
}).then(function (err) {
if (err === null) {
fulfill()
} else {
driver.manage().logs().get('browser').then(function (logs) {
Expand All @@ -38,13 +38,7 @@ export function waitUntilMapReady (driver) {
})
}
})
if (val === 'NOEXIST') {
reject('Map does not exist after 20 ms')
} else if (val === 'NOREADY') {
reject('Map not ready after 2000 ms')
} else {
reject('Unknown value')
}
reject(err)
}
})
})
Expand Down

0 comments on commit aee8fe4

Please sign in to comment.