jeudi 20 août 2015

Ember Component Integration Tests: `link-to` href empty

I'm trying to write a component integration test, a la this blog post, but my component has a link-to to a dynamic route and the href property isn't being filled in. Here is a simplified version of what I'm trying to do.

My component's template:

{{#link-to "myModel" model}}

And here is the relevant part of my test:

this.set('model', {
  id: 'myId',
  name: 'My Name'
});

this.render(hbs`
{{my-component model=model}}
`);

assert.equal(this.$('a').attr('href'), '/myModel/myId'); // fails

The link-to is rendered, just without an href attribute. If I log the HTML in the test, it looks like:

<a id="ember283" class="ember-view">My Name</a>

Is there something I need to do to my "model" to get the link-to to have an href? I tried to look at the tests for link-to in ember, and found this part of the tests, which is basically what I'm doing – provide a POJO with the id key set. Any ideas?




Aucun commentaire:

Enregistrer un commentaire