Skip to content

Commit

Permalink
Merge pull request #53 from GavinJoyce/gj/allow-colocated-test-files
Browse files Browse the repository at this point in the history
allow colocated test files
  • Loading branch information
rwjblue authored Apr 17, 2018
2 parents d3e4a88 + 6b6e40c commit f9c3eac
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ function registerInstanceInitializers(app, moduleNames) {
}
}

function _endsWith(str, suffix) {
return str.indexOf(suffix, str.length - suffix.length) !== -1;
}

export default function (app, prefix) {
var initializerPrefix = prefix + '/initializers/';
var instanceInitializerPrefix = prefix + '/instance-initializers/';
Expand All @@ -34,9 +38,13 @@ export default function (app, prefix) {
for (var i = 0; i < moduleNames.length; i++) {
var moduleName = moduleNames[i];
if (moduleName.lastIndexOf(initializerPrefix, 0) === 0) {
initializers.push(moduleName);
if (!_endsWith(moduleName, '-test')) {
initializers.push(moduleName);
}
} else if (moduleName.lastIndexOf(instanceInitializerPrefix, 0) === 0) {
instanceInitializers.push(moduleName);
if (!_endsWith(moduleName, '-test')) {
instanceInitializers.push(moduleName);
}
}
}
registerInitializers(app, initializers);
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
"ember-data": "^2.17.0",
"ember-disable-prototype-extensions": "^1.1.2",
"ember-export-application-global": "^2.0.0",
"ember-load-initializers": "^1.0.0",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-resolver": "^4.0.0",
"ember-source": "~3.0.0",
Expand Down
1 change: 1 addition & 0 deletions tests/dummy/app/initializers/foo-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
1 change: 1 addition & 0 deletions tests/dummy/app/instance-initializers/bar-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};

0 comments on commit f9c3eac

Please sign in to comment.