Merge branch 'master' of https://github.com/mooglemoogle/jasmine-ajax into mooglemoogle-master

- Merges #147
- Fixes #142
This commit is contained in:
Gregg Van Hove 2016-02-16 16:59:04 -08:00
commit cef5bbcc6c
3 changed files with 16 additions and 0 deletions

View File

@ -278,6 +278,7 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
this.username = arguments[3];
this.password = arguments[4];
this.readyState = 1;
this.requestHeaders = {};
this.eventBus.trigger('readystatechange');
},

View File

@ -98,6 +98,20 @@ describe('FakeRequest', function() {
expect(request.contentType()).toEqual('application/text+xml');
});
it('clears the request headers when opened', function() {
// Requirement #14 https://www.w3.org/TR/XMLHttpRequest/#the-open()-method
var request = new this.FakeRequest();
request.setRequestHeader('X-Header1', 'value1');
expect(request.requestHeaders['X-Header1']).toEqual('value1');
request.open();
expect(request.requestHeaders['X-Header1']).not.toBeDefined();
expect(request.requestHeaders).toEqual({});
});
describe('managing readyState', function() {
beforeEach(function() {
this.request = new this.FakeRequest();

View File

@ -116,6 +116,7 @@ getJasmineRequireObj().AjaxFakeRequest = function(eventBusFactory) {
this.username = arguments[3];
this.password = arguments[4];
this.readyState = 1;
this.requestHeaders = {};
this.eventBus.trigger('readystatechange');
},