Skip to content

Commit

Permalink
Merge pull request #90 from poetic/location-type-errors
Browse files Browse the repository at this point in the history
Added check to tell the user if the locationType is not set to hash
  • Loading branch information
jakecraige committed Nov 7, 2014
2 parents acca1e9 + b6fa9d4 commit 2c4043b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
}
};
21 changes: 21 additions & 0 deletions node-tests/unit/addon-test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
});
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion tests/dummy/config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 2c4043b

Please sign in to comment.