diff --git a/.travis.yml b/.travis.yml index 68b59ab..a661550 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,8 @@ language: node_js node_js: - "4" + - "6" + - "7" sudo: false @@ -9,23 +11,13 @@ cache: directories: - node_modules -env: - - EMBER_TRY_SCENARIO=default - - EMBER_TRY_SCENARIO=ember-1.13 - - EMBER_TRY_SCENARIO=ember-release - - EMBER_TRY_SCENARIO=ember-beta - - EMBER_TRY_SCENARIO=ember-canary - matrix: fast_finish: true - allow_failures: - - env: EMBER_TRY_SCENARIO=ember-canary before_install: - npm config set spin false - - npm install -g bower + - npm install -g bower phantomjs-prebuilt - bower --version - - npm install phantomjs-prebuilt - phantomjs --version install: @@ -35,4 +27,4 @@ install: script: # Usually, it's ok to finish the test scenario without reverting # to the addon's original dependency state, skipping "cleanup". - - ember try:one $EMBER_TRY_SCENARIO test --skip-cleanup + - node_modules/.bin/ember try:each --skip-cleanup diff --git a/README.md b/README.md index 652d007..98372ae 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,11 @@ -# Ember-cordova-splash +# ember-cordova-splash + +[![Build Status](https://travis-ci.org/isleofcode/ember-cordova-splash.svg?branch=master)](https://travis-ci.org/isleofcode/ember-cordova-splash) Ember service bound to Cordova/Phonegap/Crosswalk splashscreen -management for use in [ember-cordova](https://embercordova.com). See -website for usage. +management for use in [ember-cordova](http://embercordova.com). See +website for detailed usage. + +``` +ember install ember-cordova-splash +``` diff --git a/addon/services/ember-cordova/splash.js b/addon/services/ember-cordova/splash.js index b6e6af8..4dad261 100644 --- a/addon/services/ember-cordova/splash.js +++ b/addon/services/ember-cordova/splash.js @@ -1,4 +1,3 @@ -/* global navigator */ import Ember from 'ember'; const { @@ -8,18 +7,30 @@ const { export default Service.extend({ hide() { - document.addEventListener('deviceready', function() { + document.addEventListener('deviceready', () => { + const navigator = window.navigator; if (isPresent(navigator) && isPresent(navigator.splashscreen)) { navigator.splashscreen.hide(); + } else { + this.error('hide'); } }); }, show() { - document.addEventListener('deviceready', function() { + document.addEventListener('deviceready', () => { + const navigator = window.navigator; if (isPresent(navigator) && isPresent(navigator.splashscreen)) { navigator.splashscreen.show(); + } else { + this.error('show'); } }); + }, + + error(fnName) { + console.warn(`ember-cordova/splash: + Trying to call ${fnName} but splash plugin is not accessible` + ); } }); diff --git a/bower.json b/bower.json index d566552..73dad3a 100644 --- a/bower.json +++ b/bower.json @@ -3,6 +3,7 @@ "dependencies": { "ember": "~2.7.0", "ember-cli-shims": "0.1.1", - "ember-qunit-notifications": "0.1.0" + "ember-qunit-notifications": "0.1.0", + "testdouble": "testdouble/testdouble.js#^1.4.2" } } diff --git a/package.json b/package.json index f7b8236..7c93b39 100644 --- a/package.json +++ b/package.json @@ -1,23 +1,20 @@ { "name": "ember-cordova-splash", "version": "0.1.0", - "description": "The default blueprint for ember-cli addons.", + "description": "ember-cordova splash addon", + "homepage": "https://github.com/isleofcode/ember-cordova-splash", "directories": { "test": "tests" }, - "license": "MIT", - "repository": "", "engines": { "node": ">= 0.10.0" }, - "author": { "name": "Alex Blom", "email": "alex@isleofcode.com", "url": "https://isleofcode.com" }, - "contributors": [ { "name": "Aidan Nulman", @@ -30,7 +27,10 @@ "url": "https://isleofcode.com" } ], - + "repository": { + "type": "git", + "url": "git+https://github.com/isleofcode/ember-cordova-splash.git" + }, "keywords": [ "ember-addon", "cordova", @@ -42,17 +42,21 @@ "ember-cordova", "ember-cordova-splash" ], - + "scripts": { + "test": "ember try:each" + }, "devDependencies": { "broccoli-asset-rev": "^2.4.2", - "ember-cli": "2.7.0", - "ember-cli-app-version": "^1.0.0", - "ember-cli-dependency-checker": "^1.2.0", + "ember-cli": "2.11.1", + "ember-cli-app-version": "^2.0.0", + "ember-cli-dependency-checker": "^1.3.0", + "ember-cli-htmlbars": "^1.1.1", "ember-cli-jshint": "^1.0.0", "ember-cli-qunit": "^2.0.0", "ember-cli-release": "^0.2.9", "ember-cli-sri": "^2.1.0", "ember-cli-test-loader": "^1.1.0", + "ember-cli-testdouble": "0.1.0", "ember-cli-uglify": "^1.2.0", "ember-disable-prototype-extensions": "^1.1.0", "ember-export-application-global": "^1.0.5", @@ -60,11 +64,9 @@ "ember-resolver": "^2.0.3", "loader.js": "^4.0.1" }, - "dependencies": { "ember-cli-babel": "^5.1.6" }, - "ember-addon": { "configPath": "tests/dummy/config" } diff --git a/tests/integration/services/ember-cordova/splash-test.js b/tests/integration/services/ember-cordova/splash-test.js new file mode 100644 index 0000000..d72152b --- /dev/null +++ b/tests/integration/services/ember-cordova/splash-test.js @@ -0,0 +1,34 @@ +/* global Event */ +import { moduleFor, test } from 'ember-qunit'; +import td from 'testdouble'; + +const fireDeviceReady = function() { + window.document.dispatchEvent(new Event('deviceready')); +}; + +moduleFor('service:ember-cordova/splash', 'Integration | Service | cordova/splash', { + integration: true, + + afterEach: function() { + td.reset(); + } +}); + +test('proxies show/hide events', function(assert) { + assert.expect(0); + let splashService = this.subject(); + + let pluginDouble = td.object({ + hide: function() {}, + show: function() {} + }); + + window.navigator.splashscreen = pluginDouble; + + splashService.hide(); + splashService.show(); + fireDeviceReady(); + + td.verify(pluginDouble.hide()); + td.verify(pluginDouble.show()); +});