diff --git a/.eslintrc.js b/.eslintrc.js new file mode 100644 index 0000000..fad934f --- /dev/null +++ b/.eslintrc.js @@ -0,0 +1,21 @@ +module.exports = { + root: true, + parserOptions: { + ecmaVersion: 6, + sourceType: 'module' + }, + extends: [ + 'eslint:recommended', + 'plugin:ember-suave/recommended' + ], + env: { + browser: true + }, + rules: { + 'ember-suave/no-const-outside-module-scope': 'off', + 'ember-suave/no-direct-property-access': 'off' + }, + globals: { + 'google': true + } +}; diff --git a/.gitignore b/.gitignore index 133af36..52fa8e7 100644 --- a/.gitignore +++ b/.gitignore @@ -13,9 +13,8 @@ /connect.lock /coverage/* /libpeerconnection.log -npm-debug.log +npm-debug.log* testem.log -lcov.dat # IDE misc /.idea diff --git a/.jscsrc b/.jscsrc deleted file mode 100644 index 28a8841..0000000 --- a/.jscsrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "preset": "ember-suave", - "excludeFiles": ["blanket-options.js"], - "requireEnhancedObjectLiterals": null, - "disallowConstOutsideModuleScope": null, - "disallowPositionalParamsExtend": null -} diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index 793a094..0000000 --- a/.jshintrc +++ /dev/null @@ -1,33 +0,0 @@ -{ - "predef": [ - "document", - "window", - "-Promise", - "google" - ], - "browser": true, - "boss": true, - "curly": true, - "debug": false, - "devel": true, - "eqeqeq": true, - "evil": true, - "forin": false, - "immed": false, - "laxbreak": false, - "newcap": true, - "noarg": true, - "noempty": false, - "nonew": false, - "nomen": false, - "onevar": false, - "plusplus": false, - "regexp": false, - "undef": true, - "sub": true, - "strict": false, - "white": false, - "eqnull": true, - "esnext": true, - "unused": true -} diff --git a/.npmignore b/.npmignore index fa8b147..889b2bf 100644 --- a/.npmignore +++ b/.npmignore @@ -8,7 +8,7 @@ .editorconfig .ember-cli .gitignore -.jshintrc +.eslintrc.js .watchmanconfig .travis.yml bower.json diff --git a/.travis.yml b/.travis.yml index ea902b5..dc86786 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,20 +1,23 @@ --- language: node_js node_js: - - "4" + - "6" sudo: false cache: directories: - - node_modules + - $HOME/.npm + - $HOME/.cache # includes bowers cache env: - - EMBER_TRY_SCENARIO=default - - EMBER_TRY_SCENARIO=ember-1.13 + # we recommend testing LTS's and latest stable release (bonus points to beta/canary) + - EMBER_TRY_SCENARIO=ember-lts-2.4 + - EMBER_TRY_SCENARIO=ember-lts-2.8 - EMBER_TRY_SCENARIO=ember-release - EMBER_TRY_SCENARIO=ember-beta - EMBER_TRY_SCENARIO=ember-canary + - EMBER_TRY_SCENARIO=ember-default matrix: fast_finish: true @@ -24,18 +27,19 @@ matrix: before_install: - npm config set spin false - - npm install -g bower - - npm install phantomjs-prebuilt + - npm install -g bower phantomjs-prebuilt + - bower --version + - phantomjs --version install: - npm install - bower install script: - - ember try $EMBER_TRY_SCENARIO test + - COVERAGE=true node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup after_script: - - cat lcov.dat | node_modules/coveralls/bin/coveralls.js + - cat coverage/lcov.info | node_modules/coveralls/bin/coveralls.js -notifications: email: diff --git a/README.md b/README.md index 0cebf35..ab3a38f 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ In `config/environment.js` you can specify: - additional Google Maps libraries to be loaded along with this add-on (check the full list [here](https://developers.google.com/maps/documentation/javascript/libraries)), - optional API key or client ID for your application (additional info could be found [here](https://developers.google.com/maps/web/)), +- optional [channel](https://developers.google.com/maps/premium/reports/usage-reports#channels), - optional version number, - optional exclude parameter, which prevents inclusion of the google maps api script tag into the index.html (in case one wants to handle loading of google maps lib by himself), - optional language for map localization, diff --git a/addon/components/g-map-address-marker.js b/addon/components/g-map-address-marker.js index f244e51..56821cf 100644 --- a/addon/components/g-map-address-marker.js +++ b/addon/components/g-map-address-marker.js @@ -5,7 +5,7 @@ import layout from '../templates/components/g-map-address-marker'; const { computed, observer, run, isPresent, isEmpty, typeOf } = Ember; const GMapAddressMarkerComponent = Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map-address-marker'], map: computed.alias('mapContext.map'), @@ -23,9 +23,9 @@ const GMapAddressMarkerComponent = Ember.Component.extend({ const map = this.get('map'); let service = this.get('placesService'); - if (isPresent(map) && - isEmpty(service) && - (typeof FastBoot === 'undefined')) { + if (isPresent(map) + && isEmpty(service) + && (typeof FastBoot === 'undefined')) { service = new google.maps.places.PlacesService(map); this.set('placesService', service); this.searchLocation(); @@ -40,9 +40,9 @@ const GMapAddressMarkerComponent = Ember.Component.extend({ const service = this.get('placesService'); const address = this.get('address'); - if (isPresent(service) && - isPresent(address) && - (typeof FastBoot === 'undefined')) { + if (isPresent(service) + && isPresent(address) + && (typeof FastBoot === 'undefined')) { const request = { query: address }; service.textSearch(request, (results, status) => { @@ -54,12 +54,14 @@ const GMapAddressMarkerComponent = Ember.Component.extend({ }, updateLocation(results) { - const lat = results[0].geometry.location.lat(); - const lng = results[0].geometry.location.lng(); + if (!this.destroyed) { + const lat = results[0].geometry.location.lat(); + const lng = results[0].geometry.location.lng(); - this.set('lat', lat); - this.set('lng', lng); - this.sendOnLocationChange(lat, lng, results); + this.set('lat', lat); + this.set('lng', lng); + this.sendOnLocationChange(lat, lng, results); + } }, sendOnLocationChange() { diff --git a/addon/components/g-map-address-route.js b/addon/components/g-map-address-route.js index 95421c8..8d7bc92 100644 --- a/addon/components/g-map-address-route.js +++ b/addon/components/g-map-address-route.js @@ -5,7 +5,7 @@ import layout from '../templates/components/g-map-address-route'; const { computed, observer, run, isPresent, isEmpty, typeOf } = Ember; const GMapAddressRouteComponent = Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map-address-route'], map: computed.alias('mapContext.map'), @@ -23,9 +23,9 @@ const GMapAddressRouteComponent = Ember.Component.extend({ const map = this.get('map'); let service = this.get('placesService'); - if (isPresent(map) && - isEmpty(service) && - (typeof FastBoot === 'undefined')) { + if (isPresent(map) + && isEmpty(service) + && (typeof FastBoot === 'undefined')) { service = new google.maps.places.PlacesService(map); this.set('placesService', service); this.searchLocations(); @@ -41,9 +41,9 @@ const GMapAddressRouteComponent = Ember.Component.extend({ const originAddress = this.get('originAddress'); const destinationAddress = this.get('destinationAddress'); - if (isPresent(service) && - isPresent(originAddress) && - (typeof FastBoot === 'undefined')) { + if (isPresent(service) + && isPresent(originAddress) + && (typeof FastBoot === 'undefined')) { const originRequest = { query: originAddress }; service.textSearch(originRequest, (results, status) => { @@ -53,9 +53,9 @@ const GMapAddressRouteComponent = Ember.Component.extend({ }); } - if (isPresent(service) && - isPresent(destinationAddress) && - (typeof FastBoot === 'undefined')) { + if (isPresent(service) + && isPresent(destinationAddress) + && (typeof FastBoot === 'undefined')) { const destinationRequest = { query: destinationAddress }; service.textSearch(destinationRequest, (results, status) => { @@ -67,21 +67,25 @@ const GMapAddressRouteComponent = Ember.Component.extend({ }, updateOriginLocation(results) { - const lat = results[0].geometry.location.lat(); - const lng = results[0].geometry.location.lng(); + if (!this.isDestroyed) { + const lat = results[0].geometry.location.lat(); + const lng = results[0].geometry.location.lng(); - this.set('originLat', lat); - this.set('originLng', lng); - this.sendOnLocationsChange(lat, lng, results); + this.set('originLat', lat); + this.set('originLng', lng); + this.sendOnLocationsChange(lat, lng, results); + } }, updateDestinationLocation(results) { - const lat = results[0].geometry.location.lat(); - const lng = results[0].geometry.location.lng(); + if (!this.isDestroyed) { + const lat = results[0].geometry.location.lat(); + const lng = results[0].geometry.location.lng(); - this.set('destinationLat', lat); - this.set('destinationLng', lng); - this.sendOnLocationsChange(lat, lng, results); + this.set('destinationLat', lat); + this.set('destinationLng', lng); + this.sendOnLocationsChange(lat, lng, results); + } }, sendOnLocationsChange() { diff --git a/addon/components/g-map-infowindow.js b/addon/components/g-map-infowindow.js index 43aa9e9..1c21ef8 100644 --- a/addon/components/g-map-infowindow.js +++ b/addon/components/g-map-infowindow.js @@ -9,11 +9,11 @@ const { isEmpty, isPresent, observer, computed, run, assert, typeOf } = Ember; const allowedOptions = Ember.A(['disableAutoPan', 'maxWidth', 'pixelOffset']); const OPEN_CLOSE_EVENTS = Ember.A( - [ 'click', 'dblclick', 'rightclick', 'mouseover', 'mouseout' ] + ['click', 'dblclick', 'rightclick', 'mouseover', 'mouseout'] ); const GMapInfowindowComponent = Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map-marker'], map: computed.alias('mapContext.map'), @@ -143,10 +143,10 @@ const GMapInfowindowComponent = Ember.Component.extend({ const lat = this.get('lat'); const lng = this.get('lng'); - if (isPresent(infowindow) && - isPresent(lat) && - isPresent(lng) && - (typeof FastBoot === 'undefined')) { + if (isPresent(infowindow) + && isPresent(lat) + && isPresent(lng) + && (typeof FastBoot === 'undefined')) { const position = new google.maps.LatLng(lat, lng); infowindow.setPosition(position); } diff --git a/addon/components/g-map-marker.js b/addon/components/g-map-marker.js index ef4784e..5ef7386 100644 --- a/addon/components/g-map-marker.js +++ b/addon/components/g-map-marker.js @@ -5,7 +5,7 @@ import GMapComponent from './g-map'; const { isEmpty, isPresent, observer, computed, run, assert, typeOf } = Ember; const GMapMarkerComponent = Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map-marker'], map: computed.alias('mapContext.map'), @@ -25,8 +25,8 @@ const GMapMarkerComponent = Ember.Component.extend({ didInsertElement() { this._super(); - if (isEmpty(this.get('marker')) && - (typeof FastBoot === 'undefined')) { + if (isEmpty(this.get('marker')) + && (typeof FastBoot === 'undefined')) { const marker = new google.maps.Marker(); this.set('marker', marker); } @@ -118,10 +118,10 @@ const GMapMarkerComponent = Ember.Component.extend({ const lat = this.get('lat'); const lng = this.get('lng'); - if (isPresent(marker) && - isPresent(lat) && - isPresent(lng) && - (typeof FastBoot === 'undefined')) { + if (isPresent(marker) + && isPresent(lat) + && isPresent(lng) + && (typeof FastBoot === 'undefined')) { const position = new google.maps.LatLng(lat, lng); if (isPresent(position)) { marker.setPosition(position); diff --git a/addon/components/g-map-polyline-coordinate.js b/addon/components/g-map-polyline-coordinate.js index 4167813..747515c 100644 --- a/addon/components/g-map-polyline-coordinate.js +++ b/addon/components/g-map-polyline-coordinate.js @@ -5,7 +5,7 @@ import GMapPolylineComponent from './g-map-polyline'; const { isEmpty, isPresent, observer, computed, run, assert } = Ember; const GMapPolylineCoordinateComponent = Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map-polyline-coordinate'], polyline: computed.alias('polylineContext.polyline'), diff --git a/addon/components/g-map-polyline.js b/addon/components/g-map-polyline.js index 69dd5c3..d87b697 100644 --- a/addon/components/g-map-polyline.js +++ b/addon/components/g-map-polyline.js @@ -8,7 +8,7 @@ const { isEmpty, isPresent, observer, computed, run, assert, typeOf } = Ember; const allowedPolylineOptions = Ember.A(['strokeColor', 'strokeWeight', 'strokeOpacity', 'zIndex', 'geodesic', 'icons', 'clickable', 'draggable', 'visible', 'path']); const GMapPolylineComponent = Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map-polyline'], map: computed.alias('mapContext.map'), diff --git a/addon/components/g-map-route-address-waypoint.js b/addon/components/g-map-route-address-waypoint.js index cc75b58..ad22423 100644 --- a/addon/components/g-map-route-address-waypoint.js +++ b/addon/components/g-map-route-address-waypoint.js @@ -4,7 +4,7 @@ import layout from '../templates/components/g-map-route-address-waypoint'; const { isEmpty, isPresent, observer, computed, run } = Ember; const GMapRouteAddressWaypointComponent = Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map-route-address-waypoint'], map: computed.alias('routeContext.map'), @@ -18,9 +18,9 @@ const GMapRouteAddressWaypointComponent = Ember.Component.extend({ const map = this.get('map'); let service = this.get('placesService'); - if (isPresent(map) && - isEmpty(service) && - (typeof FastBoot === 'undefined')) { + if (isPresent(map) + && isEmpty(service) + && (typeof FastBoot === 'undefined')) { service = new google.maps.places.PlacesService(map); this.set('placesService', service); @@ -48,11 +48,13 @@ const GMapRouteAddressWaypointComponent = Ember.Component.extend({ }, updateLocation(results) { - const lat = results[0].geometry.location.lat(); - const lng = results[0].geometry.location.lng(); + if (!this.isDestroyed) { + const lat = results[0].geometry.location.lat(); + const lng = results[0].geometry.location.lng(); - this.set('lat', lat); - this.set('lng', lng); + this.set('lat', lat); + this.set('lng', lng); + } } }); diff --git a/addon/components/g-map-route-waypoint.js b/addon/components/g-map-route-waypoint.js index e7b760f..ad0e397 100644 --- a/addon/components/g-map-route-waypoint.js +++ b/addon/components/g-map-route-waypoint.js @@ -5,7 +5,7 @@ import GMapRouteComponent from './g-map-route'; const { isEmpty, isPresent, observer, computed, run, assert } = Ember; const GMapRouteWaypointComponent = Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map-route-waypoint'], map: computed.alias('routeContext.map'), @@ -37,12 +37,12 @@ const GMapRouteWaypointComponent = Ember.Component.extend({ updateWaypoint() { const { lat, lng } = this.getProperties(['lat', 'lng']); - if (isPresent(lat) && - isPresent(lng) && - (typeof FastBoot === 'undefined')) { + if (isPresent(lat) + && isPresent(lng) + && (typeof FastBoot === 'undefined')) { let location = new google.maps.LatLng(lat, lng); this.set('waypoint', { - location: location, + location, stopover: this.get('stopover') }); } diff --git a/addon/components/g-map-route.js b/addon/components/g-map-route.js index 8e6be51..38622cf 100644 --- a/addon/components/g-map-route.js +++ b/addon/components/g-map-route.js @@ -15,7 +15,7 @@ const TRAVEL_MODES = { }; const GMapRouteComponent = Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map-marker'], positionalParams: ['mapContext'], @@ -49,12 +49,12 @@ const GMapRouteComponent = Ember.Component.extend({ let service = this.get('directionsService'); let renderer = this.get('directionsRenderer'); - if (isPresent(map) && - isEmpty(service) && - isEmpty(renderer) && - (typeof FastBoot === 'undefined')) { + if (isPresent(map) + && isEmpty(service) + && isEmpty(renderer) + && (typeof FastBoot === 'undefined')) { const rendererOptions = { - map: map, + map, suppressMarkers: true, preserveViewport: true }; @@ -82,18 +82,18 @@ const GMapRouteComponent = Ember.Component.extend({ const destinationLng = this.get('destinationLng'); const waypoints = this.get('waypoints').mapBy('waypoint'); - if (isPresent(service) && isPresent(renderer) && - isPresent(originLat) && isPresent(originLng) && - isPresent(destinationLat) && isPresent(destinationLng) && - (typeof FastBoot === 'undefined')) { + if (isPresent(service) && isPresent(renderer) + && isPresent(originLat) && isPresent(originLng) + && isPresent(destinationLat) && isPresent(destinationLng) + && (typeof FastBoot === 'undefined')) { const origin = new google.maps.LatLng(this.get('originLat'), this.get('originLng')); const destination = new google.maps.LatLng(this.get('destinationLat'), this.get('destinationLng')); const travelMode = this.retrieveTravelMode(this.get('travelMode')); const request = { - origin: origin, - destination: destination, - travelMode: travelMode, - waypoints: waypoints + origin, + destination, + travelMode, + waypoints }; service.route(request, (response, status) => { diff --git a/addon/components/g-map.js b/addon/components/g-map.js index 56dfc63..083b475 100644 --- a/addon/components/g-map.js +++ b/addon/components/g-map.js @@ -4,7 +4,7 @@ import layout from '../templates/components/g-map'; const { isEmpty, isPresent, computed, observer, run } = Ember; export default Ember.Component.extend({ - layout: layout, + layout, classNames: ['g-map'], bannedOptions: Ember.A(['center', 'zoom']), @@ -30,8 +30,8 @@ export default Ember.Component.extend({ didInsertElement() { this._super(); - if (isEmpty(this.get('map')) && - (typeof FastBoot === 'undefined')) { + if (isEmpty(this.get('map')) + && (typeof FastBoot === 'undefined')) { const canvas = this.$().find('.g-map-canvas').get(0); const options = this.get('permittedOptions'); this.set('map', new google.maps.Map(canvas, options)); @@ -76,10 +76,10 @@ export default Ember.Component.extend({ const lat = this.get('lat'); const lng = this.get('lng'); - if (isPresent(map) && - isPresent(lat) && - isPresent(lng) && - (typeof FastBoot === 'undefined')) { + if (isPresent(map) + && isPresent(lat) + && isPresent(lng) + && (typeof FastBoot === 'undefined')) { const center = new google.maps.LatLng(lat, lng); map.setCenter(center); } @@ -116,8 +116,8 @@ export default Ember.Component.extend({ return isPresent(marker.get('lat')) && isPresent(marker.get('lng')); }); - if (markers.length > 0 && - (typeof FastBoot === 'undefined')) { + if (markers.length > 0 + && (typeof FastBoot === 'undefined')) { const map = this.get('map'); const bounds = new google.maps.LatLngBounds(); const points = markers.map((marker) => { diff --git a/bower.json b/bower.json index 7cf22e9..e778030 100644 --- a/bower.json +++ b/bower.json @@ -1,13 +1,6 @@ { "name": "ember-g-map", "dependencies": { - "ember": "2.9.1", - "ember-cli-shims": "0.1.1", - "ember-cli-test-loader": "0.2.2", "sinonjs": "~1.17.1" - }, - "devDependencies": { - "blanket": "5e94fc30f2e694bb5c3718ddcbf60d467f4b4d26", - "ember-qunit-notifications": "0.1.0" } } diff --git a/config/ember-try.js b/config/ember-try.js index 014f603..a070124 100644 --- a/config/ember-try.js +++ b/config/ember-try.js @@ -1,20 +1,35 @@ -/*jshint node:true*/ +/* eslint-env node */ module.exports = { scenarios: [ { - name: 'default', + name: 'ember-lts-2.4', bower: { - dependencies: { } + dependencies: { + 'ember': 'components/ember#lts-2-4' + }, + resolutions: { + 'ember': 'lts-2-4' + } + }, + npm: { + devDependencies: { + 'ember-source': null + } } }, { - name: 'ember-1.13', + name: 'ember-lts-2.8', bower: { dependencies: { - 'ember': '~1.13.0' + 'ember': 'components/ember#lts-2-8' }, resolutions: { - 'ember': '~1.13.0' + 'ember': 'lts-2-8' + } + }, + npm: { + devDependencies: { + 'ember-source': null } } }, @@ -27,6 +42,11 @@ module.exports = { resolutions: { 'ember': 'release' } + }, + npm: { + devDependencies: { + 'ember-source': null + } } }, { @@ -38,6 +58,11 @@ module.exports = { resolutions: { 'ember': 'beta' } + }, + npm: { + devDependencies: { + 'ember-source': null + } } }, { @@ -49,6 +74,17 @@ module.exports = { resolutions: { 'ember': 'canary' } + }, + npm: { + devDependencies: { + 'ember-source': null + } + } + }, + { + name: 'ember-default', + npm: { + devDependencies: {} } } ] diff --git a/config/environment.js b/config/environment.js index ff703bc..e98c141 100644 --- a/config/environment.js +++ b/config/environment.js @@ -1,5 +1,5 @@ +/* eslint-env node */ 'use strict'; -/* jshint node: true */ module.exports = function(/* environment, appConfig */) { return { diff --git a/ember-cli-build.js b/ember-cli-build.js index 4ac3913..5e6f037 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -1,6 +1,5 @@ -/*jshint node:true*/ -/* global require, module */ -var EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); +/* eslint-env node */ +const EmberAddon = require('ember-cli/lib/broccoli/ember-addon'); module.exports = function(defaults) { var app = new EmberAddon(defaults, { diff --git a/index.js b/index.js index c6e72a9..c7dc8c6 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -/* jshint node: true */ +/* eslint-env node */ 'use strict'; module.exports = { @@ -21,22 +21,27 @@ module.exports = { if (key) { params.push('key=' + encodeURIComponent(key)); } - + var version = gMapConfig.version; if (version) { params.push('v=' + encodeURIComponent(version)); } - + var client = gMapConfig.client; if (client) { params.push('client=' + encodeURIComponent(client)); } + var channel = gMapConfig.channel; + if (channel) { + params.push('channel=' + encodeURIComponent(channel)); + } + var libraries = gMapConfig.libraries; if (libraries && libraries.length) { params.push('libraries=' + encodeURIComponent(libraries.join(','))); } - + var language = gMapConfig.language; if (language) { params.push('language=' + encodeURIComponent(language)); @@ -49,7 +54,7 @@ module.exports = { src += '?' + params.join('&'); content = ''; - + var exclude = gMapConfig.exclude; if (exclude) { content = '' diff --git a/package.json b/package.json index e52d05a..2033de5 100644 --- a/package.json +++ b/package.json @@ -13,38 +13,42 @@ }, "repository": "https://github.com/asennikov/ember-g-map", "engines": { - "node": ">= 0.10.0" + "node": ">= 4" }, "author": "Alexander Sennikov (gseno88@gmail.com)", "license": "MIT", "devDependencies": { - "broccoli-asset-rev": "^2.4.2", + "broccoli-asset-rev": "^2.4.5", "coveralls": "^2.11.4", - "ember-ajax": "2.0.1", - "ember-cli": "^2.6.3", + "ember-ajax": "2.4.1", + "ember-cli": "^2.12.1", "ember-cli-app-version": "^1.0.0", - "ember-cli-blanket": "0.9.5", - "ember-cli-dependency-checker": "^1.2.0", + "ember-cli-code-coverage": "^0.3.12", + "ember-cli-dependency-checker": "^1.3.0", + "ember-cli-eslint": "^3.0.3", "ember-cli-github-pages": "0.0.6", - "ember-cli-htmlbars": "^1.0.3", - "ember-cli-htmlbars-inline-precompile": "^0.3.1", - "ember-cli-inject-live-reload": "^1.4.0", - "ember-cli-jshint": "^1.0.0", - "ember-cli-qunit": "^1.4.0", + "ember-cli-htmlbars": "^1.1.1", + "ember-cli-htmlbars-inline-precompile": "^0.3.6", + "ember-cli-inject-live-reload": "^1.4.1", + "ember-cli-qunit": "^3.1.2", "ember-cli-release": "0.2.9", + "ember-cli-shims": "^1.0.2", "ember-cli-sri": "^2.1.0", + "ember-cli-test-loader": "^2.1.0", "ember-cli-uglify": "^1.2.0", "ember-data": "^2.6.0", "ember-disable-prototype-extensions": "^1.1.0", "ember-export-application-global": "^1.0.5", - "ember-load-initializers": "^0.5.1", + "ember-factory-for-polyfill": "^1.1.1", + "ember-load-initializers": "^1.0.0", "ember-resolver": "^2.0.3", "ember-runtime-enumerable-includes-polyfill": "1.0.2", - "ember-sinon": "0.3.0", - "ember-sinon-qunit": "1.0.0", - "ember-suave": "2.0.1", - "ember-welcome-page": "^1.0.1", - "loader.js": "^4.0.1" + "ember-sinon": "0.7.0", + "ember-sinon-qunit": "1.5.0", + "ember-source": "~2.12.1", + "ember-welcome-page": "^2.0.2", + "eslint-plugin-ember-suave": "^1.0.0", + "loader.js": "^4.2.3" }, "keywords": [ "ember-addon", @@ -56,8 +60,8 @@ "maps" ], "dependencies": { - "ember-cli-babel": "^5.1.6", - "ember-cli-htmlbars": "^1.0.5" + "ember-cli-babel": "^5.2.4", + "ember-cli-htmlbars": "^1.1.1" }, "ember-addon": { "configPath": "tests/dummy/config" diff --git a/testem.js b/testem.js index 3c30ad0..b234048 100644 --- a/testem.js +++ b/testem.js @@ -1,12 +1,12 @@ -/*jshint node:true*/ +/* eslint-env node */ module.exports = { - "framework": "qunit", "test_page": "tests/index.html?hidepassed", "disable_watching": true, "launch_in_ci": [ "PhantomJS" ], "launch_in_dev": [ + "PhantomJS", "Chrome" ] }; diff --git a/tests/.eslintrc.js b/tests/.eslintrc.js new file mode 100644 index 0000000..fbf2555 --- /dev/null +++ b/tests/.eslintrc.js @@ -0,0 +1,5 @@ +module.exports = { + env: { + embertest: true + } +}; diff --git a/tests/.jshintrc b/tests/.jshintrc deleted file mode 100644 index b602816..0000000 --- a/tests/.jshintrc +++ /dev/null @@ -1,53 +0,0 @@ -{ - "predef": [ - "document", - "window", - "location", - "setTimeout", - "$", - "-Promise", - "define", - "console", - "visit", - "exists", - "fillIn", - "click", - "keyEvent", - "triggerEvent", - "find", - "findWithAssert", - "wait", - "DS", - "google", - "andThen", - "currentURL", - "currentPath", - "currentRouteName" - ], - "node": false, - "browser": false, - "boss": true, - "curly": true, - "debug": false, - "devel": false, - "eqeqeq": true, - "evil": true, - "forin": false, - "immed": false, - "laxbreak": false, - "newcap": true, - "noarg": true, - "noempty": false, - "nonew": false, - "nomen": false, - "onevar": false, - "plusplus": false, - "regexp": false, - "undef": true, - "sub": true, - "strict": false, - "white": false, - "eqnull": true, - "esnext": true, - "unused": true -} diff --git a/tests/blanket-options.js b/tests/blanket-options.js deleted file mode 100644 index 3ed3df5..0000000 --- a/tests/blanket-options.js +++ /dev/null @@ -1,25 +0,0 @@ -/* globals blanket, module */ - -var options = { - modulePrefix: 'ember-g-map', - filter: '//.*ember-g-map/.*/', - antifilter: '//.*(tests|template).*/', - loaderExclusions: [], - enableCoverage: true, - cliOptions: { - reporters: ['lcov'], - autostart: true, - lcovOptions: { - outputFile: 'lcov.dat', - renamer: function(moduleName){ - var expression = /^ember-g-map/; - return moduleName.replace(expression, 'addon') + '.js'; - } - } - } -}; -if (typeof exports === 'undefined') { - blanket.options(options); -} else { - module.exports = options; -} diff --git a/tests/dummy/app/index.html b/tests/dummy/app/index.html index c9b4327..5120bd7 100644 --- a/tests/dummy/app/index.html +++ b/tests/dummy/app/index.html @@ -9,16 +9,16 @@ {{content-for "head"}} - - + + {{content-for "head-footer"}} {{content-for "body"}} - - + + {{content-for "body-footer"}} diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js index 3bba78e..cdc2578 100644 --- a/tests/dummy/app/router.js +++ b/tests/dummy/app/router.js @@ -2,7 +2,8 @@ import Ember from 'ember'; import config from './config/environment'; const Router = Ember.Router.extend({ - location: config.locationType + location: config.locationType, + rootURL: config.rootURL }); Router.map(function() { diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js index 889cfaa..867a572 100644 --- a/tests/dummy/config/environment.js +++ b/tests/dummy/config/environment.js @@ -1,15 +1,19 @@ -/* jshint node: true */ +/* eslint-env node */ module.exports = function(environment) { var ENV = { modulePrefix: 'dummy', environment: environment, - baseURL: '/', + rootURL: '/', locationType: 'auto', EmberENV: { FEATURES: { // Here you can enable experimental features on an ember canary build // e.g. 'with-controller': true + }, + EXTEND_PROTOTYPES: { + // Prevent Ember Data from overriding Date.parse. + Date: false } }, @@ -38,7 +42,7 @@ module.exports = function(environment) { if (environment === 'test') { // Testem prefers this... - ENV.baseURL = '/'; + ENV.rootURL = '/'; ENV.locationType = 'none'; // keep test console output quieter @@ -49,7 +53,7 @@ module.exports = function(environment) { } if (environment === 'production') { - ENV.baseURL = '/ember-g-map'; + ENV.rootURL = '/ember-g-map'; } return ENV; diff --git a/tests/helpers/module-for-acceptance.js b/tests/helpers/module-for-acceptance.js index 78584ef..76996fd 100644 --- a/tests/helpers/module-for-acceptance.js +++ b/tests/helpers/module-for-acceptance.js @@ -11,12 +11,12 @@ export default function(name, options = {}) { this.application = startApp(); if (options.beforeEach) { - return options.beforeEach(...arguments); + return options.beforeEach.apply(this, arguments); } }, afterEach() { - let afterEach = options.afterEach && options.afterEach(...arguments); + let afterEach = options.afterEach && options.afterEach.apply(this, arguments); return Promise.resolve(afterEach).then(() => destroyApp(this.application)); } }); diff --git a/tests/helpers/start-app.js b/tests/helpers/start-app.js index e098f1d..9a605eb 100644 --- a/tests/helpers/start-app.js +++ b/tests/helpers/start-app.js @@ -3,16 +3,13 @@ import Application from '../../app'; import config from '../../config/environment'; export default function startApp(attrs) { - let application; - let attributes = Ember.merge({}, config.APP); attributes = Ember.merge(attributes, attrs); // use defaults, but you can override; - Ember.run(() => { - application = Application.create(attributes); + return Ember.run(() => { + let application = Application.create(attributes); application.setupForTesting(); application.injectTestHelpers(); + return application; }); - - return application; } diff --git a/tests/index.html b/tests/index.html index 660a036..5209b85 100644 --- a/tests/index.html +++ b/tests/index.html @@ -10,26 +10,22 @@ {{content-for "head"}} {{content-for "test-head"}} - - - - + + + {{content-for "head-footer"}} {{content-for "test-head-footer"}} - {{content-for "body"}} {{content-for "test-body"}} - - - - - - - - + + + + + + {{content-for "body-footer"}} {{content-for "test-body-footer"}} diff --git a/tests/test-helper.js b/tests/test-helper.js index e6cfb70..d560aa5 100644 --- a/tests/test-helper.js +++ b/tests/test-helper.js @@ -1,6 +1,8 @@ import resolver from './helpers/resolver'; +import TestLoader from 'ember-cli-test-loader/test-support'; import { setResolver } from 'ember-qunit'; setResolver(resolver); +TestLoader.load(); diff --git a/tests/unit/components/g-map-address-marker-test.js b/tests/unit/components/g-map-address-marker-test.js index e4116da..a10bf80 100644 --- a/tests/unit/components/g-map-address-marker-test.js +++ b/tests/unit/components/g-map-address-marker-test.js @@ -1,26 +1,26 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; -import GMapComponent from 'ember-g-map/components/g-map'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; -let fakePlacesService; -let component; +let fakePlacesService, component; moduleForComponent('g-map-address-marker', 'Unit | Component | g map address marker', { // Specify the other units that are required for this test // needs: ['component:foo', 'helper:bar'], unit: true, + needs: ['component:g-map'], beforeEach() { fakePlacesService = { textSearch: sinon.stub() }; sinon.stub(google.maps.places, 'PlacesService').returns(fakePlacesService); + const GMapComponent = Ember.getOwner(this).factoryFor('component:g-map'); component = this.subject({ - mapContext: new GMapComponent() + mapContext: GMapComponent.create() }); }, diff --git a/tests/unit/components/g-map-address-route-test.js b/tests/unit/components/g-map-address-route-test.js index 96fd2c6..6144ac7 100644 --- a/tests/unit/components/g-map-address-route-test.js +++ b/tests/unit/components/g-map-address-route-test.js @@ -1,26 +1,26 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; -import GMapComponent from 'ember-g-map/components/g-map'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; -let fakePlacesService; -let component; +let fakePlacesService, component; moduleForComponent('g-map-address-route', 'Unit | Component | g map address route', { // Specify the other units that are required for this test // needs: ['component:foo', 'helper:bar'], unit: true, + needs: ['component:g-map'], beforeEach() { fakePlacesService = { textSearch: sinon.stub() }; sinon.stub(google.maps.places, 'PlacesService').returns(fakePlacesService); + const GMapComponent = Ember.getOwner(this).factoryFor('component:g-map'); component = this.subject({ - mapContext: new GMapComponent() + mapContext: GMapComponent.create() }); }, diff --git a/tests/unit/components/g-map-infowindow-test.js b/tests/unit/components/g-map-infowindow-test.js index 3876543..643ee32 100644 --- a/tests/unit/components/g-map-infowindow-test.js +++ b/tests/unit/components/g-map-infowindow-test.js @@ -1,18 +1,17 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; -import GMapComponent from 'ember-g-map/components/g-map'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; -let fakeInfowindowObject; -let component; +let fakeInfowindowObject, component; moduleForComponent('g-map-infowindow', 'Unit | Component | g map infowindow', { // Specify the other units that are required for this test // needs: ['component:foo', 'helper:bar'], unit: true, + needs: ['component:g-map'], beforeEach() { fakeInfowindowObject = { @@ -24,7 +23,8 @@ moduleForComponent('g-map-infowindow', 'Unit | Component | g map infowindow', { }; sinon.stub(google.maps, 'InfoWindow').returns(fakeInfowindowObject); - const mapContext = new GMapComponent(); + const GMapComponent = Ember.getOwner(this).factoryFor('component:g-map'); + const mapContext = GMapComponent.create(); mapContext.registerInfowindow = sinon.stub(); mapContext.unregisterInfowindow = sinon.stub(); diff --git a/tests/unit/components/g-map-marker-test.js b/tests/unit/components/g-map-marker-test.js index ec11d10..65ba4ba 100644 --- a/tests/unit/components/g-map-marker-test.js +++ b/tests/unit/components/g-map-marker-test.js @@ -1,18 +1,17 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; -import GMapComponent from 'ember-g-map/components/g-map'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; -let fakeMarkerObject; -let component; +let fakeMarkerObject, component; moduleForComponent('g-map-marker', 'Unit | Component | g map marker', { // Specify the other units that are required for this test // needs: ['component:foo', 'helper:bar'], unit: true, + needs: ['component:g-map'], beforeEach() { fakeMarkerObject = { @@ -26,8 +25,9 @@ moduleForComponent('g-map-marker', 'Unit | Component | g map marker', { addListener: sinon.stub() }; sinon.stub(google.maps, 'Marker').returns(fakeMarkerObject); + const GMapComponent = Ember.getOwner(this).factoryFor('component:g-map'); component = this.subject({ - mapContext: new GMapComponent() + mapContext: GMapComponent.create() }); }, diff --git a/tests/unit/components/g-map-polyline-coordinate-test.js b/tests/unit/components/g-map-polyline-coordinate-test.js index 93b2c0a..5c0a94d 100644 --- a/tests/unit/components/g-map-polyline-coordinate-test.js +++ b/tests/unit/components/g-map-polyline-coordinate-test.js @@ -1,26 +1,24 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; -import GMapComponent from 'ember-g-map/components/g-map'; -import GMapPolylineComponent from 'ember-g-map/components/g-map-polyline'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; -let fakePolylineCoordinateObject; -let component; +let fakePolylineCoordinateObject, component; moduleForComponent('g-map-polyline-coordinate', 'Unit | Component | g map polyline coordinate', { // Specify the other units that are required for this test - needs: ['component:g-map-polyline'], unit: true, + needs: ['component:g-map', 'component:g-map-polyline'], beforeEach() { fakePolylineCoordinateObject = { setPosition: sinon.stub() }; sinon.stub(google.maps, 'LatLng').returns(fakePolylineCoordinateObject); - + const GMapComponent = Ember.getOwner(this).factoryFor('component:g-map'); + const GMapPolylineComponent = Ember.getOwner(this).factoryFor('component:g-map-polyline'); const mapComponent = GMapComponent.create(); component = this.subject({ polylineContext: GMapPolylineComponent.create({ mapContext: mapComponent }) @@ -78,7 +76,7 @@ test('it calls `setPath` of google polyline on `setPosition` with coordinates pr polylineContext: fakePolylineObject })); run(() => component.setPosition()); - sinon.assert.called(fakePolylineObject.setPath, 2); + sinon.assert.called(fakePolylineObject.setPath); }); test('it doesn\'t call `setPosition` of google polyline on `setPosition` when no lat present', function() { diff --git a/tests/unit/components/g-map-polyline-test.js b/tests/unit/components/g-map-polyline-test.js index b06d229..51be346 100644 --- a/tests/unit/components/g-map-polyline-test.js +++ b/tests/unit/components/g-map-polyline-test.js @@ -1,18 +1,17 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; -import GMapComponent from 'ember-g-map/components/g-map'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; -let fakePolylineObject; -let component; +let fakePolylineObject, component; moduleForComponent('g-map-polyline', 'Unit | Component | g map polyline', { // Specify the other units that are required for this test // needs: ['component:foo', 'helper:bar'], unit: true, + needs: ['component:g-map'], beforeEach() { fakePolylineObject = { @@ -22,8 +21,9 @@ moduleForComponent('g-map-polyline', 'Unit | Component | g map polyline', { addListener: sinon.stub() }; sinon.stub(google.maps, 'Polyline').returns(fakePolylineObject); + const GMapComponent = Ember.getOwner(this).factoryFor('component:g-map'); component = this.subject({ - mapContext: new GMapComponent() + mapContext: GMapComponent.create() }); }, diff --git a/tests/unit/components/g-map-route-address-waypoint-test.js b/tests/unit/components/g-map-route-address-waypoint-test.js index a868444..aed61f0 100644 --- a/tests/unit/components/g-map-route-address-waypoint-test.js +++ b/tests/unit/components/g-map-route-address-waypoint-test.js @@ -1,19 +1,17 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; -import GMapComponent from 'ember-g-map/components/g-map'; -import GMapRouteComponent from 'ember-g-map/components/g-map-route'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; -let fakePlacesService; -let component; +let fakePlacesService, component; moduleForComponent('g-map-route-address-waypoint', 'Unit | Component | g map route address waypoint', { // Specify the other units that are required for this test // needs: ['component:foo', 'helper:bar'], unit: true, + needs: ['component:g-map', 'component:g-map-route'], beforeEach() { fakePlacesService = { @@ -21,6 +19,8 @@ moduleForComponent('g-map-route-address-waypoint', 'Unit | Component | g map rou }; sinon.stub(google.maps.places, 'PlacesService').returns(fakePlacesService); + const GMapComponent = Ember.getOwner(this).factoryFor('component:g-map'); + const GMapRouteComponent = Ember.getOwner(this).factoryFor('component:g-map-route'); const mapComponent = GMapComponent.create(); component = this.subject({ routeContext: GMapRouteComponent.create({ mapContext: mapComponent }) diff --git a/tests/unit/components/g-map-route-test.js b/tests/unit/components/g-map-route-test.js index 3a65536..671a928 100644 --- a/tests/unit/components/g-map-route-test.js +++ b/tests/unit/components/g-map-route-test.js @@ -1,19 +1,17 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; -import GMapComponent from 'ember-g-map/components/g-map'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; -let fakeDirectionsService; -let fakeDirectionsRenderer; -let component; +let fakeDirectionsService, fakeDirectionsRenderer, component; moduleForComponent('g-map-route', 'Unit | Component | g map route', { // Specify the other units that are required for this test // needs: ['component:foo', 'helper:bar'], unit: true, + needs: ['component:g-map'], beforeEach() { fakeDirectionsService = { @@ -27,8 +25,9 @@ moduleForComponent('g-map-route', 'Unit | Component | g map route', { }; sinon.stub(google.maps, 'DirectionsRenderer').returns(fakeDirectionsRenderer); sinon.stub(google.maps, 'DirectionsService').returns(fakeDirectionsService); + const GMapComponent = Ember.getOwner(this).factoryFor('component:g-map'); component = this.subject({ - mapContext: new GMapComponent() + mapContext: GMapComponent.create() }); }, @@ -172,8 +171,8 @@ test('it calls `route` of directionsService on `updateRoute`', function() { run(() => component.updateRoute()); const correctRequest = { - origin: origin, - destination: destination, + origin, + destination, travelMode: google.maps.TravelMode.DRIVING, waypoints: [] }; diff --git a/tests/unit/components/g-map-route-waypoint-test.js b/tests/unit/components/g-map-route-waypoint-test.js index 8c59426..9c81cc2 100644 --- a/tests/unit/components/g-map-route-waypoint-test.js +++ b/tests/unit/components/g-map-route-waypoint-test.js @@ -1,22 +1,21 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; -import GMapComponent from 'ember-g-map/components/g-map'; -import GMapRouteComponent from 'ember-g-map/components/g-map-route'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; -let fakeMarkerObject; -let routeComponent; -let component; +let fakeMarkerObject, routeComponent, component; moduleForComponent('g-map-route-waypoint', 'Unit | Component | g map route waypoint', { // Specify the other units that are required for this test // needs: ['component:foo', 'helper:bar'], unit: true, + needs: ['component:g-map', 'component:g-map-route'], beforeEach() { + const GMapComponent = Ember.getOwner(this).factoryFor('component:g-map'); + const GMapRouteComponent = Ember.getOwner(this).factoryFor('component:g-map-route'); const mapComponent = GMapComponent.create(); routeComponent = GMapRouteComponent.create({ mapContext: mapComponent, diff --git a/tests/unit/components/g-map-test.js b/tests/unit/components/g-map-test.js index 5b81d56..ddffc40 100644 --- a/tests/unit/components/g-map-test.js +++ b/tests/unit/components/g-map-test.js @@ -1,6 +1,6 @@ import Ember from 'ember'; import { moduleForComponent } from 'ember-qunit'; -import test from '../../ember-sinon-qunit/test'; +import test from 'ember-sinon-qunit/test-support/test'; import sinon from 'sinon'; const { run } = Ember; @@ -303,7 +303,7 @@ test('it calls `fitBounds` of google map on `fitToMarkers`', function() { stubbedLatLng.onCall(0).returns(firstMarker); stubbedLatLng.onCall(1).returns(secondMarker); - run(() => component.set('markers', [ firstMarker, secondMarker ])); + run(() => component.set('markers', [firstMarker, secondMarker])); run(() => component.fitToMarkers()); sinon.assert.calledOnce(google.maps.LatLngBounds); @@ -360,7 +360,7 @@ test('it calls `closeInfowindow` for each marker in group on `groupMarkerClicked const secondMarker = Ember.Object.create({ group: 'black' }); const thirdMarker = Ember.Object.create({ group: 'blue' }); const fourthMarker = Ember.Object.create({ group: 'blue' }); - const markers = Ember.A([ firstMarker, secondMarker, thirdMarker, fourthMarker ]); + const markers = Ember.A([firstMarker, secondMarker, thirdMarker, fourthMarker]); markers.forEach((marker) => marker.closeInfowindow = sinon.stub()); const component = this.subject();