How can I test the onreadystatechange on XMLHttpRequest or pure Javascript AJAX without jQuery? I\'m doing this because I\'m developing Firefox extension. I guess I have to use
You can test it in such manner
it("should make XHR request", function() {
// arrange
var xhr = {
open: jasmine.createSpy('open')
};
XMLHttpRequest = jasmine.createSpy('XMLHttpRequest');
XMLHttpRequest.and.callFake(function () {
return xhr;
});
// act
submit();
// assert
expect(xhr.open).toHaveBeenCalled();
});