Added readyState changes to FakeXmlHttpRequest.
Took out rogue console.error.
This commit is contained in:
parent
ec1867e944
commit
a4d3881e7e
@ -21,6 +21,7 @@ function FakeXMLHttpRequest() {
|
||||
open: function() {
|
||||
xhr.method = arguments[0];
|
||||
xhr.url = arguments[1];
|
||||
xhr.readyState = 1;
|
||||
},
|
||||
|
||||
setRequestHeader: function(header, value) {
|
||||
@ -28,14 +29,19 @@ function FakeXMLHttpRequest() {
|
||||
},
|
||||
|
||||
abort: function() {
|
||||
xhr.readyState = 0;
|
||||
},
|
||||
|
||||
readyState: 0,
|
||||
|
||||
onreadystatechange: function() {
|
||||
},
|
||||
|
||||
status: null,
|
||||
|
||||
send: function(data) {
|
||||
xhr.params = data;
|
||||
xhr.readyState = 2;
|
||||
},
|
||||
|
||||
getResponseHeader: function(name) {
|
||||
|
38
spec/javascripts/fake-xml-http-request-spec.js
Normal file
38
spec/javascripts/fake-xml-http-request-spec.js
Normal file
@ -0,0 +1,38 @@
|
||||
describe("FakeXMLHttpRequest", function() {
|
||||
var xhr;
|
||||
beforeEach(function() {
|
||||
xhr = new FakeXMLHttpRequest();
|
||||
});
|
||||
it("should have an initial readyState of 0 (uninitialized)", function() {
|
||||
expect(xhr.readyState).toEqual(0);
|
||||
});
|
||||
describe("when opened", function() {
|
||||
beforeEach(function() {
|
||||
xhr.open("GET", "http://example.com")
|
||||
});
|
||||
it("should have a readyState of 1 (open)", function() {
|
||||
expect(xhr.readyState).toEqual(1);
|
||||
});
|
||||
|
||||
describe("when sent", function() {
|
||||
it("should have a readyState of 2 (sent)", function() {
|
||||
xhr.send(null);
|
||||
expect(xhr.readyState).toEqual(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a response comes in", function() {
|
||||
it("should have a readyState of 4 (loaded)", function() {
|
||||
xhr.response({status: 200});
|
||||
expect(xhr.readyState).toEqual(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe("when aborted", function() {
|
||||
it("should have a readyState of 0 (uninitialized)", function() {
|
||||
xhr.abort();
|
||||
expect(xhr.readyState).toEqual(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -311,7 +311,6 @@ function sharedAjaxResponseBehaviorForJQuery_Failure(context) {
|
||||
var xhr;
|
||||
beforeEach(function() {
|
||||
xhr = context.responseCallback.mostRecentCall.args[0];
|
||||
console.error("=============> xhr: ", xhr);
|
||||
});
|
||||
|
||||
it("should have the expected status code", function() {
|
||||
|
Loading…
Reference in New Issue
Block a user