By performing the following Jasmine test (1), the test succeeds, but I am facing recursive loading of the main test page.
Here is my test (1) and here is the module on which I run the test (2):
Any ideas? How can I fix the problem?
PS:
The problem only affects the Chrome browser and Safari.
Here is an example: jsfiddle.net/shioyama/EXvZY
(1)
describe('When Submit button handler fired', function () {
beforeEach(function () {
spyOn(MyView.prototype, 'submitForm');
this.view = new MyView();
this.view.render();
this.view.$el.find('form').submit();
});
it('submitForm should be called', function () {
expect(MyView.prototype.submitForm).toHaveBeenCalled();
});
});
(2)
var MyView = Backbone.View.extend({
events: {
'submit form' : 'submitForm'
},
submitForm: function (event) {
event.preventDefault();
}
});
source
share