From d6a4ae5c4be7b73b1329109c91a06653d11af0b9 Mon Sep 17 00:00:00 2001 From: Daniel Ochoa Date: Thu, 6 Nov 2014 17:15:54 -0600 Subject: [PATCH 1/2] Added check to tell the user if the locationType is not set to hash --- index.js | 6 ++++++ node-tests/unit/addon-test.js | 22 ++++++++++++++++++++++ package.json | 2 +- tests/dummy/config/environment.js | 2 +- 4 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 node-tests/unit/addon-test.js diff --git a/index.js b/index.js index 9e817b3..fc9f069 100644 --- a/index.js +++ b/index.js @@ -81,5 +81,11 @@ module.exports = { } return tree; + }, + + config: function(env, baseConfig) { + if (env !== 'test' && baseConfig.locationType !== 'hash') { + throw new Error('ember-cli-cordova: You must specify the locationType as \'hash\' in your environment.js'); + } } }; diff --git a/node-tests/unit/addon-test.js b/node-tests/unit/addon-test.js new file mode 100644 index 0000000..e6d9cb0 --- /dev/null +++ b/node-tests/unit/addon-test.js @@ -0,0 +1,22 @@ +var addon = require('../../index'); + +function expectWithConfig(baseConfig, env) { + return expect(addon.config.bind(addon, env || 'development', baseConfig)); +} + +describe('Addon', function() { + describe('config', function() { + describe('validates location type', function() { + it('should throw Error', function() { + expectWithConfig({locationType: 'auto'}).to.throw(Error); + }); + it('should not throw an error', function() { + var baseConfig = {locationType: 'hash'}; + expectWithConfig({locationType: 'hash'}).to.not.throw(Error); + }); + it('should not throw an error on test', function() { + expectWithConfig({locationType: 'auto'}, 'test').to.not.throw(Error); + }); + }); + }); +}); diff --git a/package.json b/package.json index d427524..f087552 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "repository": "https://github.com/poetic/ember-cli-cordova.git", "main": "index.js", "scripts": { - "node-test": "mocha --require node-tests/helpers/_helper.js --reporter spec node-tests/**/*-test.js", + "node-test": "mocha --require node-tests/helpers/_helper.js --reporter spec node-tests/**/*-test.js node-tests/**/**/*-test.js", "ember-test": "ember test", "test": "npm run node-test && npm run ember-test" }, diff --git a/tests/dummy/config/environment.js b/tests/dummy/config/environment.js index bc0d538..56e9988 100644 --- a/tests/dummy/config/environment.js +++ b/tests/dummy/config/environment.js @@ -5,7 +5,7 @@ module.exports = function(environment) { modulePrefix: 'dummy', environment: environment, baseURL: '/', - locationType: 'auto', + locationType: 'hash', EmberENV: { FEATURES: { // Here you can enable experimental features on an ember canary build From b6fa9d4f4df4aeb32047f80f2824a30dea211adb Mon Sep 17 00:00:00 2001 From: Daniel Ochoa Date: Thu, 6 Nov 2014 17:18:44 -0600 Subject: [PATCH 2/2] Update addon-test.js --- node-tests/unit/addon-test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/node-tests/unit/addon-test.js b/node-tests/unit/addon-test.js index e6d9cb0..30ad1af 100644 --- a/node-tests/unit/addon-test.js +++ b/node-tests/unit/addon-test.js @@ -11,7 +11,6 @@ describe('Addon', function() { expectWithConfig({locationType: 'auto'}).to.throw(Error); }); it('should not throw an error', function() { - var baseConfig = {locationType: 'hash'}; expectWithConfig({locationType: 'hash'}).to.not.throw(Error); }); it('should not throw an error on test', function() {