Skip to content

Commit

Permalink
Merge pull request #122 from rwjblue/tweaks-for-islegacy
Browse files Browse the repository at this point in the history
Restrict integration: 'legacy' to component tests.
  • Loading branch information
rwjblue committed Nov 23, 2015
2 parents b071b17 + f54487d commit b04cc9c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 16 deletions.
8 changes: 4 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
],
"dependencies": {
"klassy": "cerebris/klassy.js#0.1.0",
"ember": "^1.13.0"
"ember": "^2.2.0"
},
"devDependencies": {
"qunit": "^1.15.0",
"ember-data": "1.13.9",
"ember-data": "^2.2.0",
"pretender": "~0.10.1",
"loader.js": "ember-cli/loader.js#3.0.0",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.6",
"ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
"jquery": "~2.1.1"
}
}
}
29 changes: 25 additions & 4 deletions config/ember-try.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ module.exports = {
name: 'ember-1.13',
dependencies: {
"ember": "~1.13.8"
},
devDependencies: {
"ember-data": "~1.0.0-beta.19.2"
}
},
{
Expand All @@ -39,7 +42,25 @@ module.exports = {
"ember": "~2.0.0"
},
devDependencies: {
"ember-data": "~2.0.0-beta.2"
"ember-data": "~2.0.0"
}
},
{
name: 'ember-2.1',
dependencies: {
"ember": "~2.1.0"
},
devDependencies: {
"ember-data": "~2.1.0"
}
},
{
name: 'ember-2.2',
dependencies: {
"ember": "~2.2.0"
},
devDependencies: {
"ember-data": "~2.2.0"
}
},
{
Expand All @@ -48,7 +69,7 @@ module.exports = {
"ember": "components/ember#release"
},
devDependencies: {
"ember-data": "~2.0.0"
"ember-data": "~2.2.0"
},
resolutions: {
"ember": "release"
Expand All @@ -60,7 +81,7 @@ module.exports = {
"ember": "components/ember#beta"
},
devDependencies: {
"ember-data": "~2.0.0"
"ember-data": "~2.2.0"
},
resolutions: {
"ember": "beta"
Expand All @@ -72,7 +93,7 @@ module.exports = {
"ember": "components/ember#canary"
},
devDependencies: {
"ember-data": "~2.0.0"
"ember-data": "~2.2.0"
},
resolutions: {
"ember": "canary"
Expand Down
2 changes: 2 additions & 0 deletions lib/ember-test-helpers/test-module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Ember from 'ember';
import { getResolver } from './test-resolver';

export default TestModule.extend({
isComponentTestModule: true,

init: function(componentName, description, callbacks) {
// Allow `description` to be omitted
if (!callbacks && typeof description === 'object') {
Expand Down
12 changes: 10 additions & 2 deletions lib/ember-test-helpers/test-module.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ export default Klass.extend({
}

if (this.callbacks.integration) {
this.isLegacy = (callbacks.integration === 'legacy');
this.isIntegration = (callbacks.integration !== 'legacy');
if (this.isComponentTestModule) {
this.isLegacy = (callbacks.integration === 'legacy');
this.isIntegration = (callbacks.integration !== 'legacy');
} else {
if (callbacks.integration === 'legacy') {
throw new Error('`integration: \'legacy\'` is only valid for component tests.');
}
this.isIntegration = true;
}

delete callbacks.integration;
}

Expand Down
24 changes: 18 additions & 6 deletions tests/test-module-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ test("needs gets us the component we need", function() {
ok(otherComponent, "another component can be resolved when it's in our needs array");
});

moduleFor('component:x-foo', 'component:x-foo -- `integration: true`', {
moduleFor('component:x-foo', 'component:x-foo -- `integration`', {
beforeSetup: function() {
setupRegistry();
ok(!this.callbacks.integration, "integration property should be removed from callbacks");
Expand Down Expand Up @@ -184,6 +184,22 @@ test("throws an error when declaring integration: true and needs in the same mod
ok(result, "should throw an Error when integration: true and needs are provided");
});

test("throws an error when declaring integration: 'legacy' in `moduleFor` test", function() {
expect(3);

var result = false;

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

ok(result, "should throw an Error when integration: 'legacy' outside of a component integration test");
});

if (hasEmberVersion(1,11)) {
moduleFor('component:x-foo', 'should be able to override factories in integration mode', {
beforeSetup: function() {
Expand Down Expand Up @@ -237,10 +253,7 @@ if (hasEmberVersion(1,11)) {
});
}

if (Ember.getOwner) {
// this conditional should be changed to `hasEmberVersion` once
// `ember-container-inject-owner` lands in a stable version

if (hasEmberVersion(2, 3)) {
moduleFor('foo:thing', 'should be able to use `getOwner` on instances', {
beforeSetup: function() {
setupRegistry();
Expand All @@ -263,5 +276,4 @@ if (Ember.getOwner) {
var otherThing = owner.lookup('service:other-thing');
ok(otherThing.fromDefaultRegistry, 'was able to use `getOwner` on test context and lookup an instance');
});

}

0 comments on commit b04cc9c

Please sign in to comment.