Skip to content

Commit

Permalink
Merge pull request #78 from bcardarella/bc-throw-when-integration-and…
Browse files Browse the repository at this point in the history
…-needs-declared

Throw when integration and needs declared
  • Loading branch information
rwjblue committed Jul 31, 2015
2 parents 8afa7dc + eeaf5a7 commit de121d7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/ember-test-helpers/test-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ export default Klass.extend({
this.name = description || subjectName;
this.callbacks = callbacks || {};

if (this.callbacks.integration && this.callbacks.needs) {
throw new Error("cannot declare 'inegration: true' and 'needs' in the same module");
}

if (this.callbacks.integration) {
this.isIntegration = callbacks.integration;
delete callbacks.integration;
Expand Down
17 changes: 17 additions & 0 deletions tests/test-module-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,20 @@ test("needs is not needed (pun intended) when integration is true", function() {
var otherComponent = this.container.lookup('component:not-the-subject');
ok(otherComponent, 'another component can be resolved when integration is true');
});

test("throws an error when declaring integration: true and needs in the same module", function() {
expect(3);

var result = false;

try {
moduleFor('component:x-foo', {
integration: true,
needs: ['component:x-bar']
});
} catch(err) {
result = true;
}

ok(result, "should throw an Error when integration: true and needs are provided");
});

0 comments on commit de121d7

Please sign in to comment.