Support capturing HTTP Authentication - fixes #11

This commit is contained in:
JR Boyens 2013-01-09 00:03:52 -08:00
parent 044d02c547
commit f75b12606a
2 changed files with 17 additions and 0 deletions

View File

@ -55,6 +55,8 @@ function FakeXMLHttpRequest() {
open: function() {
this.method = arguments[0];
this.url = arguments[1];
this.username = arguments[3];
this.password = arguments[4];
this.readyState = 1;
},

View File

@ -6,6 +6,7 @@ describe("FakeXMLHttpRequest", function() {
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");
@ -36,6 +37,20 @@ describe("FakeXMLHttpRequest", function() {
});
});
describe("when opened with a username/password", function() {
beforeEach(function() {
xhr.open("GET", "http://example.com", true, "username", "password");
});
it("should store the username", function() {
expect(xhr.username).toEqual("username");
});
it("should store the password", function() {
expect(xhr.password).toEqual("password");
});
});
it("can be extended", function(){
FakeXMLHttpRequest.prototype.foo = function(){
return "foo";