0

Before upgrading to Ember CLI 1.13.1 all components generated a unit test, if my component relied on a property I may have written something like:

var supplier = var supplier = Ember.ObjectProxy.create({
    ...
});

// Creates the component instance
var component = this.subject();
assert.equal(component._state, 'preRender');

component.set('supplier', supplier);

// Renders the component to the page
this.render();
assert.equal(component._state, 'inDOM');

And this would pass/render all ok.

I am now writing an integration test for this like so:

var self = this;
Ember.run(function() {
  self.set('supplier', supplier);
});
this.render(hbs`{{widgets/add-update-order-item}}`);

The problem I have is the render errors with Cannot read property 'forEach' of undefined, part of the template has a {{each}} over supplier.prices. If I put a {{log supplier}} in the template just before the {{each}} then I see undefined. So my guess is the set hasn't happened before the render call? What do I need to do to get this working, i didn't need any callbacks or waits in the unit test form, do I now?

Adam Knights
  • 2,141
  • 1
  • 25
  • 48

1 Answers1

0

Rwjblue on github pointed out to me (https://github.com/ember-cli/ember-cli/issues/4532) that not only do you have to set the property, you also have to include it in the render. Changing my test to:

var self = this;

self.set('supplier', supplier);

this.render(hbs`{{widgets/add-update-order-item supplier=supplier}}`);

Worked.

Adam Knights
  • 2,141
  • 1
  • 25
  • 48