Skip to content

Commit

Permalink
Merge pull request #3 from isleofcode/feat/tests
Browse files Browse the repository at this point in the history
Feat/tests
  • Loading branch information
alexblom authored Mar 14, 2017
2 parents f1a0f23 + 9cdb3de commit 1d12073
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 31 deletions.
16 changes: 4 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,22 @@
language: node_js
node_js:
- "4"
- "6"
- "7"

sudo: false

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:
Expand All @@ -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
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
17 changes: 14 additions & 3 deletions addon/services/ember-cordova/splash.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global navigator */
import Ember from 'ember';

const {
Expand All @@ -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`
);
}
});
3 changes: 2 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"url": "https://isleofcode.com"
},

"contributors": [
{
"name": "Aidan Nulman",
Expand All @@ -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",
Expand All @@ -42,29 +42,31 @@
"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",
"ember-load-initializers": "^0.5.1",
"ember-resolver": "^2.0.3",
"loader.js": "^4.0.1"
},

"dependencies": {
"ember-cli-babel": "^5.1.6"
},

"ember-addon": {
"configPath": "tests/dummy/config"
}
Expand Down
34 changes: 34 additions & 0 deletions tests/integration/services/ember-cordova/splash-test.js
Original file line number Diff line number Diff line change
@@ -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());
});

0 comments on commit 1d12073

Please sign in to comment.