aboutsummaryrefslogtreecommitdiffstats
path: root/test/service
diff options
context:
space:
mode:
authorMisko Hevery2011-03-23 09:33:29 -0700
committerVojta Jina2011-08-02 01:00:03 +0200
commit8f0dcbab804180828d6859b1340c86cf161209fb (patch)
treed13d47d47a1889cb7c96a87cecacd2e25307d51c /test/service
parent1f4b417184ce53af15474de065400f8a686430c5 (diff)
downloadangular.js-8f0dcbab804180828d6859b1340c86cf161209fb.tar.bz2
feat(scope): new and improved scope implementation
- Speed improvements (about 4x on flush phase) - Memory improvements (uses no function closures) - Break $eval into $apply, $dispatch, $flush - Introduced $watch and $observe Breaks angular.equals() use === instead of == Breaks angular.scope() does not take parent as first argument Breaks scope.$watch() takes scope as first argument Breaks scope.$set(), scope.$get are removed Breaks scope.$config is removed Breaks $route.onChange callback has not "this" bounded
Diffstat (limited to 'test/service')
-rw-r--r--test/service/cookieStoreSpec.js6
-rw-r--r--test/service/cookiesSpec.js18
-rw-r--r--test/service/deferSpec.js22
-rw-r--r--test/service/exceptionHandlerSpec.js5
-rw-r--r--test/service/invalidWidgetsSpec.js8
-rw-r--r--test/service/locationSpec.js35
-rw-r--r--test/service/logSpec.js24
-rw-r--r--test/service/routeSpec.js71
-rw-r--r--test/service/updateViewSpec.js6
-rw-r--r--test/service/xhr.bulkSpec.js5
-rw-r--r--test/service/xhr.cacheSpec.js14
-rw-r--r--test/service/xhr.errorSpec.js2
-rw-r--r--test/service/xhrSpec.js3
13 files changed, 130 insertions, 89 deletions
diff --git a/test/service/cookieStoreSpec.js b/test/service/cookieStoreSpec.js
index b37e9cb0..75be924c 100644
--- a/test/service/cookieStoreSpec.js
+++ b/test/service/cookieStoreSpec.js
@@ -16,7 +16,7 @@ describe('$cookieStore', function() {
it('should serialize objects to json', function() {
$cookieStore.put('objectCookie', {id: 123, name: 'blah'});
- scope.$eval(); //force eval in test
+ scope.$flush();
expect($browser.cookies()).toEqual({'objectCookie': '{"id":123,"name":"blah"}'});
});
@@ -30,12 +30,12 @@ describe('$cookieStore', function() {
it('should delete objects from the store when remove is called', function() {
$cookieStore.put('gonner', { "I'll":"Be Back"});
- scope.$eval(); //force eval in test
+ scope.$flush(); //force eval in test
$browser.poll();
expect($browser.cookies()).toEqual({'gonner': '{"I\'ll":"Be Back"}'});
$cookieStore.remove('gonner');
- scope.$eval();
+ scope.$flush();
expect($browser.cookies()).toEqual({});
});
});
diff --git a/test/service/cookiesSpec.js b/test/service/cookiesSpec.js
index 3248fe23..cc667b56 100644
--- a/test/service/cookiesSpec.js
+++ b/test/service/cookiesSpec.js
@@ -6,7 +6,7 @@ describe('$cookies', function() {
beforeEach(function() {
$browser = new MockBrowser();
$browser.cookieHash['preexisting'] = 'oldCookie';
- scope = angular.scope(null, angular.service, {$browser: $browser});
+ scope = angular.scope(angular.service, {$browser: $browser});
scope.$cookies = scope.$service('$cookies');
});
@@ -38,13 +38,13 @@ describe('$cookies', function() {
it('should create or update a cookie when a value is assigned to a property', function() {
scope.$cookies.oatmealCookie = 'nom nom';
- scope.$eval();
+ scope.$flush();
expect($browser.cookies()).
toEqual({'preexisting': 'oldCookie', 'oatmealCookie':'nom nom'});
scope.$cookies.oatmealCookie = 'gone';
- scope.$eval();
+ scope.$flush();
expect($browser.cookies()).
toEqual({'preexisting': 'oldCookie', 'oatmealCookie': 'gone'});
@@ -56,7 +56,7 @@ describe('$cookies', function() {
scope.$cookies.nullVal = null;
scope.$cookies.undefVal = undefined;
scope.$cookies.preexisting = function(){};
- scope.$eval();
+ scope.$flush();
expect($browser.cookies()).toEqual({'preexisting': 'oldCookie'});
expect(scope.$cookies).toEqual({'preexisting': 'oldCookie'});
});
@@ -64,13 +64,13 @@ describe('$cookies', function() {
it('should remove a cookie when a $cookies property is deleted', function() {
scope.$cookies.oatmealCookie = 'nom nom';
- scope.$eval();
+ scope.$flush();
$browser.poll();
expect($browser.cookies()).
toEqual({'preexisting': 'oldCookie', 'oatmealCookie':'nom nom'});
delete scope.$cookies.oatmealCookie;
- scope.$eval();
+ scope.$flush();
expect($browser.cookies()).toEqual({'preexisting': 'oldCookie'});
});
@@ -85,16 +85,16 @@ describe('$cookies', function() {
//drop if no previous value
scope.$cookies.longCookie = longVal;
- scope.$eval();
+ scope.$flush();
expect(scope.$cookies).toEqual({'preexisting': 'oldCookie'});
//reset if previous value existed
scope.$cookies.longCookie = 'shortVal';
- scope.$eval();
+ scope.$flush();
expect(scope.$cookies).toEqual({'preexisting': 'oldCookie', 'longCookie': 'shortVal'});
scope.$cookies.longCookie = longVal;
- scope.$eval();
+ scope.$flush();
expect(scope.$cookies).toEqual({'preexisting': 'oldCookie', 'longCookie': 'shortVal'});
});
});
diff --git a/test/service/deferSpec.js b/test/service/deferSpec.js
index 7e59978c..4f651522 100644
--- a/test/service/deferSpec.js
+++ b/test/service/deferSpec.js
@@ -4,7 +4,7 @@ describe('$defer', function() {
var scope, $browser, $defer, $exceptionHandler;
beforeEach(function(){
- scope = angular.scope({}, angular.service,
+ scope = angular.scope(angular.service,
{'$exceptionHandler': jasmine.createSpy('$exceptionHandler')});
$browser = scope.$service('$browser');
$defer = scope.$service('$defer');
@@ -41,32 +41,32 @@ describe('$defer', function() {
});
- it('should call eval after each callback is executed', function() {
- var evalSpy = this.spyOn(scope, '$eval').andCallThrough();
+ it('should call $apply after each callback is executed', function() {
+ var applySpy = this.spyOn(scope, '$apply').andCallThrough();
$defer(function() {});
- expect(evalSpy).not.toHaveBeenCalled();
+ expect(applySpy).not.toHaveBeenCalled();
$browser.defer.flush();
- expect(evalSpy).toHaveBeenCalled();
+ expect(applySpy).toHaveBeenCalled();
- evalSpy.reset(); //reset the spy;
+ applySpy.reset(); //reset the spy;
$defer(function() {});
$defer(function() {});
$browser.defer.flush();
- expect(evalSpy.callCount).toBe(2);
+ expect(applySpy.callCount).toBe(2);
});
- it('should call eval even if an exception is thrown in callback', function() {
- var evalSpy = this.spyOn(scope, '$eval').andCallThrough();
+ it('should call $apply even if an exception is thrown in callback', function() {
+ var applySpy = this.spyOn(scope, '$apply').andCallThrough();
$defer(function() {throw "Test Error";});
- expect(evalSpy).not.toHaveBeenCalled();
+ expect(applySpy).not.toHaveBeenCalled();
$browser.defer.flush();
- expect(evalSpy).toHaveBeenCalled();
+ expect(applySpy).toHaveBeenCalled();
});
it('should allow you to specify the delay time', function(){
diff --git a/test/service/exceptionHandlerSpec.js b/test/service/exceptionHandlerSpec.js
index c6f13161..74f37cb9 100644
--- a/test/service/exceptionHandlerSpec.js
+++ b/test/service/exceptionHandlerSpec.js
@@ -14,11 +14,12 @@ describe('$exceptionHandler', function() {
it('should log errors', function(){
- var scope = createScope({}, {$exceptionHandler: $exceptionHandlerFactory},
- {$log: $logMock}),
+ var scope = createScope({$exceptionHandler: $exceptionHandlerFactory},
+ {$log: $logMock}),
$log = scope.$service('$log'),
$exceptionHandler = scope.$service('$exceptionHandler');
+ $log.error.rethrow = false;
$exceptionHandler('myError');
expect($log.error.logs.shift()).toEqual(['myError']);
});
diff --git a/test/service/invalidWidgetsSpec.js b/test/service/invalidWidgetsSpec.js
index 027d8d7c..fe7efe38 100644
--- a/test/service/invalidWidgetsSpec.js
+++ b/test/service/invalidWidgetsSpec.js
@@ -21,21 +21,21 @@ describe('$invalidWidgets', function() {
expect($invalidWidgets.length).toEqual(1);
scope.price = 123;
- scope.$eval();
+ scope.$digest();
expect($invalidWidgets.length).toEqual(0);
scope.$element.remove();
scope.price = 'abc';
- scope.$eval();
+ scope.$digest();
expect($invalidWidgets.length).toEqual(0);
jqLite(document.body).append(scope.$element);
scope.price = 'abcd'; //force revalidation, maybe this should be done automatically?
- scope.$eval();
+ scope.$digest();
expect($invalidWidgets.length).toEqual(1);
jqLite(document.body).html('');
- scope.$eval();
+ scope.$digest();
expect($invalidWidgets.length).toEqual(0);
});
});
diff --git a/test/service/locationSpec.js b/test/service/locationSpec.js
index f5a8c6b2..73e5e43e 100644
--- a/test/service/locationSpec.js
+++ b/test/service/locationSpec.js
@@ -46,9 +46,10 @@ describe('$location', function() {
$location.update('http://www.angularjs.org/');
$location.update({path: '/a/b'});
expect($location.href).toEqual('http://www.angularjs.org/a/b');
- expect($browser.getUrl()).toEqual(origBrowserUrl);
- scope.$eval();
expect($browser.getUrl()).toEqual('http://www.angularjs.org/a/b');
+ $location.path = '/c';
+ scope.$digest();
+ expect($browser.getUrl()).toEqual('http://www.angularjs.org/c');
});
@@ -65,7 +66,7 @@ describe('$location', function() {
it('should update hash on hashPath or hashSearch update', function() {
$location.update('http://server/#path?a=b');
- scope.$eval();
+ scope.$digest();
$location.update({hashPath: '', hashSearch: {}});
expect($location.hash).toEqual('');
@@ -74,10 +75,10 @@ describe('$location', function() {
it('should update hashPath and hashSearch on $location.hash change upon eval', function(){
$location.update('http://server/#path?a=b');
- scope.$eval();
+ scope.$digest();
$location.hash = '';
- scope.$eval();
+ scope.$digest();
expect($location.href).toEqual('http://server/');
expect($location.hashPath).toEqual('');
@@ -88,11 +89,13 @@ describe('$location', function() {
it('should update hash on $location.hashPath or $location.hashSearch change upon eval',
function() {
$location.update('http://server/#path?a=b');
- scope.$eval();
+ expect($location.href).toEqual('http://server/#path?a=b');
+ expect($location.hashPath).toEqual('path');
+ expect($location.hashSearch).toEqual({a:'b'});
+
$location.hashPath = '';
$location.hashSearch = {};
-
- scope.$eval();
+ scope.$digest();
expect($location.href).toEqual('http://server/');
expect($location.hash).toEqual('');
@@ -103,14 +106,14 @@ describe('$location', function() {
scope.$location = scope.$service('$location'); //publish to the scope for $watch
var log = '';
- scope.$watch('$location.hash', function(){
- log += this.$location.hashPath + ';';
- });
+ scope.$watch('$location.hash', function(scope){
+ log += scope.$location.hashPath + ';';
+ })();
expect(log).toEqual(';');
log = '';
scope.$location.hash = '/abc';
- scope.$eval();
+ scope.$digest();
expect(scope.$location.hash).toEqual('/abc');
expect(log).toEqual('/abc;');
});
@@ -120,7 +123,7 @@ describe('$location', function() {
it('should update hash with escaped hashPath', function() {
$location.hashPath = 'foo=bar';
- scope.$eval();
+ scope.$digest();
expect($location.hash).toBe('foo%3Dbar');
});
@@ -133,7 +136,7 @@ describe('$location', function() {
$location.host = 'host';
$location.href = 'https://hrefhost:23/hrefpath';
- scope.$eval();
+ scope.$digest();
expect($location).toEqualData({href: 'https://hrefhost:23/hrefpath',
protocol: 'https',
@@ -156,7 +159,7 @@ describe('$location', function() {
$location.host = 'host';
$location.path = '/path';
- scope.$eval();
+ scope.$digest();
expect($location).toEqualData({href: 'http://host:333/path#hash',
protocol: 'http',
@@ -237,7 +240,7 @@ describe('$location', function() {
expect($location.href).toBe('http://server');
expect($location.hash).toBe('');
- scope.$eval();
+ scope.$digest();
expect($location.href).toBe('http://server');
expect($location.hash).toBe('');
diff --git a/test/service/logSpec.js b/test/service/logSpec.js
index 80d085b8..499447ad 100644
--- a/test/service/logSpec.js
+++ b/test/service/logSpec.js
@@ -19,12 +19,12 @@ describe('$log', function() {
function warn(){ logger+= 'warn;'; }
function info(){ logger+= 'info;'; }
function error(){ logger+= 'error;'; }
- var scope = createScope({}, {$log: $logFactory},
- {$exceptionHandler: rethrow,
- $window: {console: {log: log,
- warn: warn,
- info: info,
- error: error}}}),
+ var scope = createScope({$log: $logFactory},
+ {$exceptionHandler: rethrow,
+ $window: {console: {log: log,
+ warn: warn,
+ info: info,
+ error: error}}}),
$log = scope.$service('$log');
$log.log();
@@ -38,9 +38,9 @@ describe('$log', function() {
it('should use console.log() if other not present', function(){
var logger = "";
function log(){ logger+= 'log;'; }
- var scope = createScope({}, {$log: $logFactory},
- {$window: {console:{log:log}},
- $exceptionHandler: rethrow});
+ var scope = createScope({$log: $logFactory},
+ {$window: {console:{log:log}},
+ $exceptionHandler: rethrow});
var $log = scope.$service('$log');
$log.log();
$log.warn();
@@ -51,9 +51,9 @@ describe('$log', function() {
it('should use noop if no console', function(){
- var scope = createScope({}, {$log: $logFactory},
- {$window: {},
- $exceptionHandler: rethrow}),
+ var scope = createScope({$log: $logFactory},
+ {$window: {},
+ $exceptionHandler: rethrow}),
$log = scope.$service('$log');
$log.log();
$log.warn();
diff --git a/test/service/routeSpec.js b/test/service/routeSpec.js
index fc2c7f9d..6c6c0868 100644
--- a/test/service/routeSpec.js
+++ b/test/service/routeSpec.js
@@ -18,7 +18,7 @@ describe('$route', function() {
$location, $route;
function BookChapter() {
- this.log = '<init>';
+ log += '<init>';
}
scope = compile('<div></div>')();
$location = scope.$service('$location');
@@ -28,28 +28,28 @@ describe('$route', function() {
$route.onChange(function(){
log += 'onChange();';
});
+
$location.update('http://server#/Book/Moby/Chapter/Intro?p=123');
- scope.$eval();
- expect(log).toEqual('onChange();');
+ scope.$digest();
+ expect(log).toEqual('onChange();<init>');
expect($route.current.params).toEqual({book:'Moby', chapter:'Intro', p:'123'});
- expect($route.current.scope.log).toEqual('<init>');
var lastId = $route.current.scope.$id;
log = '';
$location.update('http://server#/Blank?ignore');
- scope.$eval();
+ scope.$digest();
expect(log).toEqual('onChange();');
expect($route.current.params).toEqual({ignore:true});
expect($route.current.scope.$id).not.toEqual(lastId);
log = '';
$location.update('http://server#/NONE');
- scope.$eval();
+ scope.$digest();
expect(log).toEqual('onChange();');
expect($route.current).toEqual(null);
$route.when('/NONE', {template:'instant update'});
- scope.$eval();
+ scope.$digest();
expect($route.current.template).toEqual('instant update');
});
@@ -75,7 +75,7 @@ describe('$route', function() {
expect(onChangeSpy).not.toHaveBeenCalled();
$location.updateHash('/foo');
- scope.$eval();
+ scope.$digest();
expect($route.current.template).toEqual('foo.html');
expect($route.current.controller).toBeUndefined();
@@ -98,7 +98,7 @@ describe('$route', function() {
expect(onChangeSpy).not.toHaveBeenCalled();
$location.updateHash('/unknownRoute');
- scope.$eval();
+ scope.$digest();
expect($route.current.template).toBe('404.html');
expect($route.current.controller).toBe(NotFoundCtrl);
@@ -107,7 +107,7 @@ describe('$route', function() {
onChangeSpy.reset();
$location.updateHash('/foo');
- scope.$eval();
+ scope.$digest();
expect($route.current.template).toEqual('foo.html');
expect($route.current.controller).toBeUndefined();
@@ -115,6 +115,39 @@ describe('$route', function() {
expect(onChangeSpy).toHaveBeenCalled();
});
+ it('should $destroy old routes', function(){
+ var scope = angular.scope(),
+ $location = scope.$service('$location'),
+ $route = scope.$service('$route');
+
+ $route.when('/foo', {template: 'foo.html', controller: function(){ this.name = 'FOO';}});
+ $route.when('/bar', {template: 'bar.html', controller: function(){ this.name = 'BAR';}});
+ $route.when('/baz', {template: 'baz.html'});
+
+ expect(scope.$childHead).toEqual(null);
+
+ $location.updateHash('/foo');
+ scope.$digest();
+ expect(scope.$$childHead).toBeTruthy();
+ expect(scope.$$childHead).toEqual(scope.$$childTail);
+
+ $location.updateHash('/bar');
+ scope.$digest();
+ expect(scope.$$childHead).toBeTruthy();
+ expect(scope.$$childHead).toEqual(scope.$$childTail);
+ return
+
+ $location.updateHash('/baz');
+ scope.$digest();
+ expect(scope.$$childHead).toBeTruthy();
+ expect(scope.$$childHead).toEqual(scope.$$childTail);
+
+ $location.updateHash('/');
+ scope.$digest();
+ expect(scope.$$childHead).toEqual(null);
+ expect(scope.$$childTail).toEqual(null);
+ });
+
describe('redirection', function() {
@@ -134,7 +167,7 @@ describe('$route', function() {
expect($route.current).toBeNull();
expect(onChangeSpy).not.toHaveBeenCalled();
- scope.$eval(); //triggers initial route change - match the redirect route
+ scope.$digest(); //triggers initial route change - match the redirect route
$browser.defer.flush(); //triger route change - match the route we redirected to
expect($location.hash).toBe('/foo');
@@ -143,7 +176,7 @@ describe('$route', function() {
onChangeSpy.reset();
$location.updateHash('');
- scope.$eval(); //match the redirect route + update $browser
+ scope.$digest(); //match the redirect route + update $browser
$browser.defer.flush(); //match the route we redirected to
expect($location.hash).toBe('/foo');
@@ -152,7 +185,7 @@ describe('$route', function() {
onChangeSpy.reset();
$location.updateHash('/baz');
- scope.$eval(); //match the redirect route + update $browser
+ scope.$digest(); //match the redirect route + update $browser
$browser.defer.flush(); //match the route we redirected to
expect($location.hash).toBe('/bar');
@@ -170,10 +203,10 @@ describe('$route', function() {
$route.when('/foo/:id/foo/:subid/:extraId', {redirectTo: '/bar/:id/:subid/23'});
$route.when('/bar/:id/:subid/:subsubid', {template: 'bar.html'});
- scope.$eval();
+ scope.$digest();
$location.updateHash('/foo/id1/foo/subid3/gah');
- scope.$eval(); //triggers initial route change - match the redirect route
+ scope.$digest(); //triggers initial route change - match the redirect route
$browser.defer.flush(); //triger route change - match the route we redirected to
expect($location.hash).toBe('/bar/id1/subid3/23?extraId=gah');
@@ -190,10 +223,10 @@ describe('$route', function() {
$route.when('/bar/:id/:subid/:subsubid', {template: 'bar.html'});
$route.when('/foo/:id/:extra', {redirectTo: '/bar/:id/:subid/99'});
- scope.$eval();
+ scope.$digest();
$location.hash = '/foo/id3/eId?subid=sid1&appended=true';
- scope.$eval(); //triggers initial route change - match the redirect route
+ scope.$digest(); //triggers initial route change - match the redirect route
$browser.defer.flush(); //triger route change - match the route we redirected to
expect($location.hash).toBe('/bar/id3/sid1/99?appended=true&extra=eId');
@@ -210,10 +243,10 @@ describe('$route', function() {
$route.when('/bar/:id/:subid/:subsubid', {template: 'bar.html'});
$route.when('/foo/:id',
{redirectTo: customRedirectFn});
- scope.$eval();
+ scope.$digest();
$location.hash = '/foo/id3?subid=sid1&appended=true';
- scope.$eval(); //triggers initial route change - match the redirect route
+ scope.$digest(); //triggers initial route change - match the redirect route
$browser.defer.flush(); //triger route change - match the route we redirected to
expect($location.hash).toBe('custom');
diff --git a/test/service/updateViewSpec.js b/test/service/updateViewSpec.js
index 97366973..d8932d29 100644
--- a/test/service/updateViewSpec.js
+++ b/test/service/updateViewSpec.js
@@ -9,9 +9,9 @@ describe('$updateView', function() {
browser.isMock = false;
browser.defer = jasmine.createSpy('defer');
- scope = angular.scope(null, null, {$browser:browser});
+ scope = angular.scope(null, {$browser:browser});
$updateView = scope.$service('$updateView');
- scope.$onEval(function(){ evalCount++; });
+ scope.$observe(function(){ evalCount++; });
evalCount = 0;
});
@@ -55,7 +55,7 @@ describe('$updateView', function() {
it('should update immediatelly in test/mock mode', function(){
scope = angular.scope();
- scope.$onEval(function(){ evalCount++; });
+ scope.$observe(function(){ evalCount++; });
expect(evalCount).toEqual(0);
scope.$service('$updateView')();
expect(evalCount).toEqual(1);
diff --git a/test/service/xhr.bulkSpec.js b/test/service/xhr.bulkSpec.js
index adcb61fa..01e0a365 100644
--- a/test/service/xhr.bulkSpec.js
+++ b/test/service/xhr.bulkSpec.js
@@ -4,7 +4,10 @@ describe('$xhr.bulk', function() {
var scope, $browser, $browserXhr, $log, $xhrBulk, $xhrError, log;
beforeEach(function(){
- scope = angular.scope({}, null, {'$xhr.error': $xhrError = jasmine.createSpy('$xhr.error')});
+ scope = angular.scope(angular.service, {
+ '$xhr.error': $xhrError = jasmine.createSpy('$xhr.error'),
+ '$log': $log = {}
+ });
$browser = scope.$service('$browser');
$browserXhr = $browser.xhr;
$xhrBulk = scope.$service('$xhr.bulk');
diff --git a/test/service/xhr.cacheSpec.js b/test/service/xhr.cacheSpec.js
index f4654cd4..7bf5d40b 100644
--- a/test/service/xhr.cacheSpec.js
+++ b/test/service/xhr.cacheSpec.js
@@ -4,7 +4,7 @@ describe('$xhr.cache', function() {
var scope, $browser, $browserXhr, $xhrErr, cache, log;
beforeEach(function() {
- scope = angular.scope({}, null, {'$xhr.error': $xhrErr = jasmine.createSpy('$xhr.error')});
+ scope = angular.scope(angularService, {'$xhr.error': $xhrErr = jasmine.createSpy('$xhr.error')});
$browser = scope.$service('$browser');
$browserXhr = $browser.xhr;
cache = scope.$service('$xhr.cache');
@@ -126,22 +126,22 @@ describe('$xhr.cache', function() {
it('should call eval after callbacks for both cache hit and cache miss execute', function() {
- var evalSpy = this.spyOn(scope, '$eval').andCallThrough();
+ var flushSpy = this.spyOn(scope, '$flush').andCallThrough();
$browserXhr.expectGET('/url').respond('+');
cache('GET', '/url', null, callback);
- expect(evalSpy).not.toHaveBeenCalled();
+ expect(flushSpy).not.toHaveBeenCalled();
$browserXhr.flush();
- expect(evalSpy).toHaveBeenCalled();
+ expect(flushSpy).toHaveBeenCalled();
- evalSpy.reset(); //reset the spy
+ flushSpy.reset(); //reset the spy
cache('GET', '/url', null, callback);
- expect(evalSpy).not.toHaveBeenCalled();
+ expect(flushSpy).not.toHaveBeenCalled();
$browser.defer.flush();
- expect(evalSpy).toHaveBeenCalled();
+ expect(flushSpy).toHaveBeenCalled();
});
it('should call the error callback on error if provided', function() {
diff --git a/test/service/xhr.errorSpec.js b/test/service/xhr.errorSpec.js
index d3af4565..82fafe80 100644
--- a/test/service/xhr.errorSpec.js
+++ b/test/service/xhr.errorSpec.js
@@ -4,7 +4,7 @@ describe('$xhr.error', function() {
var scope, $browser, $browserXhr, $xhr, $xhrError, log;
beforeEach(function(){
- scope = angular.scope({}, angular.service, {
+ scope = angular.scope(angular.service, {
'$xhr.error': $xhrError = jasmine.createSpy('$xhr.error')
});
$browser = scope.$service('$browser');
diff --git a/test/service/xhrSpec.js b/test/service/xhrSpec.js
index 9f496535..b01eb385 100644
--- a/test/service/xhrSpec.js
+++ b/test/service/xhrSpec.js
@@ -4,7 +4,8 @@ describe('$xhr', function() {
var scope, $browser, $browserXhr, $log, $xhr, $xhrErr, log;
beforeEach(function(){
- var scope = angular.scope({}, null, {'$xhr.error': $xhrErr = jasmine.createSpy('xhr.error')});
+ var scope = angular.scope(angular.service, {
+ '$xhr.error': $xhrErr = jasmine.createSpy('xhr.error')});
$log = scope.$service('$log');
$browser = scope.$service('$browser');
$browserXhr = $browser.xhr;