You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've become a huge integration test fan boy recently and find that I often need to wrap my trigger (change/input/etc) with ember.run like so
test('on change will work as expected',function(assert){letissue=Issue.create({id: 1,subject: 'Broken'});letone=Status.create({id: 8,name: 'Open',issues: []});lettwo=Status.create({id: 9,name: 'Closed',issues: [1]});this.set('model',issue);this.set('statuses',Ember.A([one,two]));this.render(hbs`{{issue-detail model=model statuses=statuses}}`);let$component=this.$(".my-select-here");Ember.run(()=>{$component.val(9).trigger('change');});//assert some stuff});
In the action itself I do some type of "set" (which causes the runloop error to pop up in the test you see above). Should I wrap the trigger change in the intergration test or instead should I ember.run in the action that's invoked from the "onchange" event (and why) ?
In 2.2 closure actions will be properly wrapped in a run loop (just like non-closure actions).
For now I would add to your tests (or make a simple helper function that you use). I intend to expose some nice helpers for component integration tests (things like 'click', 'fillin', etc that you get for free in acceptance tests), so making a small helper function would make that an easy refactor in the future.
I've become a huge integration test fan boy recently and find that I often need to wrap my trigger (change/input/etc) with ember.run like so
The production select looks something like this
In the action itself I do some type of "set" (which causes the runloop error to pop up in the test you see above). Should I wrap the trigger change in the intergration test or instead should I ember.run in the action that's invoked from the "onchange" event (and why) ?
https://github.com/toranb/ember-cli-selectize/blob/master/tests/integration/components/issue-detail-test.js#L24-L26
The text was updated successfully, but these errors were encountered: