diff options
| author | Misko Hevery | 2011-10-17 16:56:56 -0700 |
|---|---|---|
| committer | Misko Hevery | 2011-11-14 16:39:31 -0800 |
| commit | 48697a2b86dbb12ea8de64cc5fece7caf68b321e (patch) | |
| tree | 1fa50659f0bb5de2640dea2a2e5bb5628f2bb14a /test/service/xhr.errorSpec.js | |
| parent | 93b777c916ccff243c5a6080bf5f39860ac7bf39 (diff) | |
| download | angular.js-48697a2b86dbb12ea8de64cc5fece7caf68b321e.tar.bz2 | |
refactor(injector): turn scope into a service
- turn scope into a $rootScope service.
- injector is now a starting point for creating angular application.
- added inject() method which wraps jasmine its/beforeEach/afterEach,
and which allows configuration and injection of services.
- refactor tests to use inject() where possible
BREAK:
- removed angular.scope() method
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'}); - }); + })); }); |
