Skip to content

Commit

Permalink
Compatibility with Ember 1.13+
Browse files Browse the repository at this point in the history
This cleans up deprecations for use with Ember 1.13+, plus one small
private API break (the changed `Resolver.create()` call).

The removed tests were all testing container resolution of things that
are deprecated. There is still coverage for container resolution of
Components, which should be sufficient.

The test suite still emits a several deprecations, but they are all
coming from Ember Data and will need to get fixed there.

I paired with @stefanpenner for this PR.
  • Loading branch information
ef4 committed Jun 14, 2015
1 parent 2f9acce commit 44fb3ba
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 76 deletions.
2 changes: 1 addition & 1 deletion Brocfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ main = concat(main, {
var vendor = concat('bower_components', {
inputFiles: ['jquery/dist/jquery.js',
'ember/ember-template-compiler.js',
'ember/ember.js',
'ember/ember.debug.js',
'ember-data/ember-data.js'],
outputFile: '/assets/vendor.js'
});
Expand Down
6 changes: 3 additions & 3 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
],
"dependencies": {
"klassy": "cerebris/klassy.js#0.1.0",
"ember": "^1.10.0"
"ember": "^1.13.0"
},
"devDependencies": {
"qunit": "^1.15.0",
"loader.js": "ember-cli/loader.js#3.0.0",
"ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
"ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
"jquery": "~2.1.1",
"ember-data": "~1.0.0-beta.10"
"ember-data": "~1.0.0-beta.19.2"
}
}
}
19 changes: 10 additions & 9 deletions lib/ember-test-helpers/test-module-for-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default TestModule.extend({
},

setupComponentIntegrationTest: function() {
var self = this;
var module = this;
var context = this.context;
context.dispatcher = Ember.EventDispatcher.create();
context.dispatcher.setup({}, '#ember-testing');
Expand All @@ -107,19 +107,20 @@ export default TestModule.extend({
if (typeof template === 'string') {
template = Ember.Handlebars.compile(template);
}
self.component = Ember.View.create({
context: context,
controller: self,
template: template,
container: self.container
module.component = Ember.Component.create({
layout: template,
container: module.container
});
module.component.set('context' ,context);
module.component.set('controller', module);

Ember.run(function() {
self.component.appendTo('#ember-testing');
module.component.appendTo('#ember-testing');
});
};

context.$ = function() {
return self.component.$.apply(self.component, arguments);
return module.component.$.apply(module.component, arguments);
};

context.set = function(key, value) {
Expand All @@ -133,7 +134,7 @@ export default TestModule.extend({
};

context.on = function(actionName, handler) {
self.actionHooks[actionName] = handler;
module.actionHooks[actionName] = handler;
};

},
Expand Down
65 changes: 3 additions & 62 deletions tests/test-module-for-component-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var PrettyColor = Ember.Component.extend({
classNames: ['pretty-color'],
attributeBindings: ['style'],
style: function(){
return 'color: ' + this.get('name') + ';';
return new Ember.Handlebars.SafeString('color: ' + this.get('name') + ';');
}.property('name')
});

Expand Down Expand Up @@ -114,65 +114,6 @@ test('can lookup components in its layout', function() {
equal(component._state, 'inDOM');
});

test('can lookup array controllers in its layout', function() {
expect(1);
var component = this.subject({
colors: ['red', 'green', 'blue'],
layout: Ember.Handlebars.compile("{{#each colors itemController='color'}}{{hexa}}{{/each}}")
});
this.render();
equal(component._state, 'inDOM');
});

test('can lookup object controllers in its layout', function() {
expect(1);
var component = this.subject({
colors: ['red', 'green', 'blue'],
layout: Ember.Handlebars.compile("{{#each colors itemController='object'}}{{this}}{{/each}}")
});
this.render();
equal(component._state, 'inDOM');
});

test('can lookup basic controllers in its layout', function() {
expect(1);
var component = this.subject({
colors: ['red', 'green', 'blue'],
layout: Ember.Handlebars.compile("{{#each colors itemController='basic'}}{{this}}{{/each}}")
});
this.render();
equal(component._state, 'inDOM');
});

test('can lookup Ember.Select in its layout', function() {
expect(1);
var component = this.subject({
colors: ['red', 'green', 'blue'],
layout: Ember.Handlebars.compile("{{view 'select'}}")
});
this.render();
equal(component._state, 'inDOM');
});

test('can lookup default Ember.Views in its layout', function() {
expect(1);
var component = this.subject({
colors: ['red', 'green', 'blue'],
layout: Ember.Handlebars.compile("{{view id='foo'}}")
});
this.render();
equal(component.$('#foo').length, 1, 'expected to find `foo` element');
});

test('can lookup toplevel Ember.Views in its layout', function() {
expect(1);
var component = this.subject({
colors: ['red', 'green', 'blue'],
layout: Ember.Handlebars.compile("{{view 'toplevel'}}")
});
this.render();
equal(component._state, 'inDOM');
});

test('clears out views from test to test', function() {
expect(1);
Expand Down Expand Up @@ -257,7 +198,7 @@ var testModule;
module('moduleForComponent: can be invoked with only the component name', {
beforeEach: function(assert) {
var done = assert.async();
testModule = new TestModuleForComponent('pretty-color');
testModule = new TestModuleForComponent('pretty-color', { unit: true });
testModule.setup()['finally'](done);
},

Expand All @@ -275,7 +216,7 @@ var testModule;
module('moduleForComponent: can be invoked with the component name and description', {
beforeEach: function(assert) {
var done = assert.async();
testModule = new TestModuleForComponent('pretty-color', 'PrettyColor');
testModule = new TestModuleForComponent('pretty-color', 'PrettyColor', { unit: true });
testModule.setup()['finally'](done);
},

Expand Down
2 changes: 1 addition & 1 deletion tests/test-support/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var Resolver = Ember.DefaultResolver.extend({
}
});

var resolver = Resolver.create({registry: {}});
var resolver = Resolver.create({registry: {}, namespace: {}});
setResolver(resolver);

export function setResolverRegistry(registry) {
Expand Down

0 comments on commit 44fb3ba

Please sign in to comment.