1

I'm trying to test a link-to href property in an ember component. with ember 2.0 but when I render the component with renter hbs it renders this:

<div id=\"23\" class=\"ember-view\">
<p><!----></p>
<div class=\"participantes\">
    <a id=\"ember282\" class=\"ember-view\">     
        <span>rnt-ayl-bld-js-jvr-frd-edw</span>
    </a>
</div>  

and the href property is not rendered, I read that is something related to router but I'm not sure how to include the router in the test I tried something like:

moduleForComponent('conversation-item', 'Integration | Component | conversation item', {
integration: true,
setup(){
    const router = this.lookup('router:main');
    router.startRouting(true);
}

});

but the lookup function is not present

TypeError: 'undefined' is not a function (evaluating 'container.lookup('router:main')')

edwinallenz
  • 340
  • 3
  • 12

1 Answers1

0

You might want to take a look at this question Ember Component Integration Tests: `link-to` href empty

Although it is 1.13 it might help you. Unfortunately I'm using ember-mocha and am still having problems.

Essentially, you're really close, you just need to use the container to look up the router.

// tests/helpers/setup-router.js

export default function({ container }) {
  const router = container.lookup('router:main');
  router.startRouting(true);
}


// tests/integration/components/my-component-test.js

import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';
import setupRouter from '../../helpers/setup-router';

moduleForComponent('my-component', 'Integration | Component | my component', {
  integration: true,
  setup() {
    setupRouter(this);
  }
});
Community
  • 1
  • 1
Jake Dluhy
  • 617
  • 6
  • 19