diff options
Diffstat (limited to 'test/service/xhr.errorSpec.js')
| -rw-r--r-- | test/service/xhr.errorSpec.js | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/test/service/xhr.errorSpec.js b/test/service/xhr.errorSpec.js index 49b63fd0..0ed5ab59 100644 --- a/test/service/xhr.errorSpec.js +++ b/test/service/xhr.errorSpec.js @@ -1,22 +1,15 @@ 'use strict'; describe('$xhr.error', function() { - var scope, $browser, $browserXhr, $xhr, $xhrError, log; + var log; - beforeEach(function() { - scope = angular.scope(angular.service, { - '$xhr.error': $xhrError = jasmine.createSpy('$xhr.error') + beforeEach(inject(function(service) { + service('$xhr.error', function(){ + return jasmine.createSpy('$xhr.error'); }); - $browser = scope.$service('$browser'); - $browserXhr = $browser.xhr; - $xhr = scope.$service('$xhr'); + service.alias('$xhr.error', '$xhrError'); log = ''; - }); - - - afterEach(function() { - dealoc(scope); - }); + })); function callback(code, response) { @@ -25,14 +18,14 @@ describe('$xhr.error', function() { } - it('should handle non 200 status codes by forwarding to error handler', function() { - $browserXhr.expectPOST('/req', 'MyData').respond(500, 'MyError'); + it('should handle non 200 status codes by forwarding to error handler', inject(function($browser, $xhr, $xhrError) { + $browser.xhr.expectPOST('/req', 'MyData').respond(500, 'MyError'); $xhr('POST', '/req', 'MyData', callback); - $browserXhr.flush(); + $browser.xhr.flush(); var cb = $xhrError.mostRecentCall.args[0].success; expect(typeof cb).toEqual('function'); expect($xhrError).toHaveBeenCalledWith( {url: '/req', method: 'POST', data: 'MyData', success: cb}, {status: 500, body: 'MyError'}); - }); + })); }); |
