lundi 29 décembre 2014

Ember.js QUnit Test Only Visible Elements With find()

I'm trying to TDD my first Ember app. I want to display one <article> element at a time. I'm getting several articles from the server. My show view defines isVisible() so that only one <article> is displayed to the user at a time.


In my test, I want to do something like:


equal(find('article').text(), 'foobar');


The problem is that it finds all the articles whether they're visible or not.


I'm fairly new to Ember so I have some ideas of what to do from here but none seems ideal.


I could look for the enclosing <div id="embernnn" class="ember-view> tags and reject the instances where Ember has applied the inline display:none style. But that would rely on the implementation rather than the abstraction.


I could use the view to add a class to the current <article> but if I have to do that then why would Ember provide the isVisible property in the View?


I'm guessing there's a better way?





Aucun commentaire:

Enregistrer un commentaire