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..30ad1af --- /dev/null +++ b/node-tests/unit/addon-test.js @@ -0,0 +1,21 @@ +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() { + 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