Trying to write a unit test for my ember controller. It just changes a property and then opens a bootstrap modal. Having difficulty figuring out how to test that the modal actually gets opened. Not sure if this even belongs in a unit test or integration test. If it's not in my unit test it seems like it will be difficult to determine code coverage later down the line. Bootstrap version: 3.3.1, ember-cli version 0.1.5, node 0.10.33. Here is what I've tried to no avail:
1.
test('loginClick() opens modal', function(){
var controller = this.subject();
$('#login-modal').on('show.bs.modal', function(){
equal(true, true, "the show.bs.modal event fired");
});
controller.send('loginClick', 'anything');
});
no assertion error
2.
test('loginClick() opens modal', function(){
var controller = this.subject();
andThen(function(){
controller.send('loginClick', 'anything');
stop();
Ember.run.later(function(){
start();
equal($('#login-modal').hasClass('in'), true, "has the 'in' class");
}, 500);
});
});
andThen is not defined
Here is the controller:
loginClick: function(param){
this.set('provider', param);//facebook or google
$('#login-modal')
.modal();
}
Any other suggestions or best practices on how to test this kind of thing will be appreciated.
p.s. Also tried adding this before click:
$.support.transition = false;
per someone's suggestion, but it does not disable the modal transition.