mardi 28 avril 2015

How do enable the format.js helpers in Ember Unit tests

I am using Ember with formatjs to internationalize my application, and ember-cli to build it all.

When I generate a component with

ember g component some-component

Ember also creates a test that checks that the component renders. However, if I use the intl-get helper from formatjs in the component template, the unit test fails.

So how can I register the custom helpers that formatjs creates for a unit test?

I first tried to add the intl-get helper:

moduleForComponent('some-component', {
  needs: ['helper:intl-get']
});

However, this just fails inside intl-get when it tries to access "intl:main". I would like for the intl initializer to run, but I am not sure if there is even application setup. Or is it some way to just mock those methods using sinon?

My current workaround is to just delete the 'it renders' tests. But I would like for these tests to pass as well, so I can further test rendering later if I want.




Aucun commentaire:

Enregistrer un commentaire