mardi 13 février 2018

Mocking conditional computed property in Ember component test

I'm trying to simply mock the computed property return value before rendering a component. Trying this.set('isHome', true) does not work though because I can't pass it to the component.

Component [Logic]:

isHome: false

Component [Template]:


  <p id="maintext">Text</p>


Test:

test('Block is visible on the homepage', function(assert) {
  assert.expect(1);
  this.set('isHome', true); // Does nothing
  this.render(template);
  let maintext = this.$("#maintext")
  this.asyncWait(assert, () => {
    assert.ok(maintext);
  });
});

This is a very rough outline of the layout, with a computed property that then is used to show a block on the page or not. How would I override that computed property to true to force that block to show?




Aucun commentaire:

Enregistrer un commentaire