Reputation: 2465
In my test, I am instantiating a component manually and appending it to DOM. For some reason I don't seem to be able to trigger the action on that component using click action, but if I were to manually call 'send' on the action then it works. Here is a jsbin link to the test: http://jsbin.com/copum/1/
//THIS DOESN'T WORK
click('button.click-me');
andThen(function(){
expect(find('#click-status').length).to.be(1);
});
/*
//THIS WORKS THOUGH
Ember.run(function(){
documentCollection.send('clickMe');
});
andThen(function(){
expect(find('#click-status').length).to.be(1);
});
*/
It seems like ember is not able to find the DOM associated with the action for some reason. Any way I can make things work with click event??
Thanks in advance.
Upvotes: 1
Views: 520
Reputation: 131
Alternatively, if you don't want to call visit('/')
, you can manually create an Ember.EventDispatcher
, just don't forget to destroy it when done.
it("should show the text when clicking the button - using click", function() {
dispatcher = Ember.EventDispatcher.create();
dispatcher.setup();
click('button.click-me');
andThen(function(){
expect(find('#click-status').length).to.be(1);
Ember.run(function(){
dispatcher.destroy();
});
});
});
Upvotes: 0
Reputation: 27407
You are just missing the visit at the top of your test :)
this now passes and works as you'd expect
it("should show the text when clicking the button - using click", function() {
visit('/');
click('button.click-me');
andThen(function(){
expect(find('#click-status').length).to.be(1);
});
});
Upvotes: 1