Am a newbie in jasmine, trying to test the jquery click call back function
$('#upload-btn').click(function(){
$("#myModal").modal('show');
});
My test code is
describe('upload button attaches to modal', function(){
it('attaches successfully', inject(function($controller, $httpBackend) {
spyOn($.fn, "click");
spyOn($.fn, "modal");
$httpBackend.expectGET('service/search/populate/procedureNumberList');
var scope = {}, ctrl = $controller('uploadARController', {
$scope : scope
});
$httpBackend.flush();
expect($('#upload-btn').click).toHaveBeenCalledWith(jasmine.any(Function));
$('#upload-btn').click();
expect($.fn.modal).toHaveBeenCalled() <<<---- Failing here;
}));
})
But am getting the below when I execute the test
PhantomJS 1.9.7 (Windows 7) Upload AR Test upload button attaches to modal attaches successfully FAILED
Expected spy modal to have been called.
PhantomJS 1.9.7 (Windows 7): Executed 3 of 3 (1 FAILED) (0.165 secs / 0.026 secs)