Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow colocated test files #53

Merged
merged 1 commit into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without these changes, the app fails to boot with:

screen shot 2018-04-16 at 14 26 54

}
}
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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing this so that we're testing the local project, not the published package

"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 {};