aboutsummaryrefslogtreecommitdiffstats
path: root/test/service/httpBackendSpec.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/service/httpBackendSpec.js')
-rw-r--r--test/service/httpBackendSpec.js23
1 files changed, 8 insertions, 15 deletions
diff --git a/test/service/httpBackendSpec.js b/test/service/httpBackendSpec.js
index b9bf2b18..1c6d3a51 100644
--- a/test/service/httpBackendSpec.js
+++ b/test/service/httpBackendSpec.js
@@ -58,18 +58,13 @@ describe('$httpBackend', function() {
$backend('POST', 'URL', null, noop, {'X-header1': 'value1', 'X-header2': 'value2'});
xhr = MockXhr.$$lastInstance;
- expect(xhr.$$headers).toEqual({
+ expect(xhr.$$reqHeaders).toEqual({
'X-header1': 'value1',
'X-header2': 'value2'
});
});
- it('should return raw xhr object', function() {
- expect($backend('GET', '/url', null, noop)).toBe(MockXhr.$$lastInstance);
- });
-
-
it('should abort request on timeout', function() {
callback.andCallFake(function(status, response) {
expect(status).toBe(-1);
@@ -91,16 +86,20 @@ describe('$httpBackend', function() {
});
- it('should be async even if xhr.send() is sync', function() {
- // IE6, IE7 is sync when serving from cache
+ it('should register onreadystatechange callback before sending', function() {
+ // send() in IE6, IE7 is sync when serving from cache
function SyncXhr() {
xhr = this;
this.open = this.setRequestHeader = noop;
+
this.send = function() {
this.status = 200;
this.responseText = 'response';
this.readyState = 4;
+ this.onreadystatechange();
};
+
+ this.getAllResponseHeaders = valueFn('');
}
callback.andCallFake(function(status, response) {
@@ -108,14 +107,8 @@ describe('$httpBackend', function() {
expect(response).toBe('response');
});
- $backend = createHttpBackend($browser, SyncXhr, fakeTimeout);
+ $backend = createHttpBackend($browser, SyncXhr);
$backend('GET', '/url', null, callback);
- expect(callback).not.toHaveBeenCalled();
-
- fakeTimeout.flush();
- expect(callback).toHaveBeenCalledOnce();
-
- (xhr.onreadystatechange || noop)();
expect(callback).toHaveBeenCalledOnce();
});