I’ve got a branch to upgrade our project from Ember CLI 0.1.12 and Ember 1.8 to Ember CLI 0.2.0 and Ember 1.10.
I have one unit test of a component which passes in the old versions and fails in the updated versions. It’s testing the rendered states of the component, which presents different classnames based on computed properties in the component. So the test looks like this:
test('#render', function () {
let tab = this.tab;
ok(this.$().find('span.wizard-tab-detail').length, "Active tab has a detail span");
// Note that both of the below states observe stepCompleted
// so we need to touch that to get them to recalculate
Ember.run( function () {
tab.set('stepCompleted', 2);
tab.set('tab', WizardTab.all()[4]);
});
ok(this.$().find('span.wizard-tab-icon-disabled').length, "Future tabs have a disabled class");
Ember.run( function () {
tab.set('stepCompleted', 3);
tab.set('tab', WizardTab.all()[1]);
});
ok(this.$().find('span.wizard-tab-icon-done').length, "Inactive tabs have a done class");
});
… and the computed properties which drive the disabled
and done
classes look like this:
completed: function() {
return this.get('stepCompleted') >= this.get('tab.stepNumber');
}.property('stepCompleted'),
disabled: function() {
return this.get('tab.stepNumber') > (this.get('stepCompleted') + 1);
}.property('stepCompleted')
The test passes its first assertion, but fails the second and third. By putting in some console.log
statements I can see the properties used by the computed properties are being changed, but the properties themselves aren’t changing.
Additional unit tests on this component which don’t check the rendered form of the component, but use similar Ember.run
blocks to update the component, all pass. So I feel like the issue is in the rendering.
What changed between 1.8 and 1.10 that could have caused this? Any other way for me to work around it?
(N.B. I also have a Stack Overflow question about this which isn’t getting much attention.)