mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
- 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
63 lines
1.7 KiB
JavaScript
63 lines
1.7 KiB
JavaScript
'use strict';
|
|
|
|
describe('$updateView', function() {
|
|
var scope, browser, evalCount, $updateView;
|
|
|
|
beforeEach(function(){
|
|
browser = new MockBrowser();
|
|
// Pretend that you are real Browser so that we see the delays
|
|
browser.isMock = false;
|
|
browser.defer = jasmine.createSpy('defer');
|
|
|
|
scope = angular.scope(null, {$browser:browser});
|
|
$updateView = scope.$service('$updateView');
|
|
scope.$observe(function(){ evalCount++; });
|
|
evalCount = 0;
|
|
});
|
|
|
|
|
|
afterEach(function(){
|
|
dealoc(scope);
|
|
});
|
|
|
|
|
|
it('should eval root scope after a delay', function(){
|
|
$updateView();
|
|
expect(evalCount).toEqual(0);
|
|
expect(browser.defer).toHaveBeenCalled();
|
|
expect(browser.defer.mostRecentCall.args[1]).toEqual(25);
|
|
browser.defer.mostRecentCall.args[0]();
|
|
expect(evalCount).toEqual(1);
|
|
});
|
|
|
|
|
|
it('should allow changing of delay time', function(){
|
|
var oldValue = angular.service('$updateView').delay;
|
|
angular.service('$updateView').delay = 50;
|
|
$updateView();
|
|
expect(evalCount).toEqual(0);
|
|
expect(browser.defer).toHaveBeenCalled();
|
|
expect(browser.defer.mostRecentCall.args[1]).toEqual(50);
|
|
angular.service('$updateView').delay = oldValue;
|
|
});
|
|
|
|
|
|
it('should ignore multiple requests for update', function(){
|
|
$updateView();
|
|
$updateView();
|
|
expect(evalCount).toEqual(0);
|
|
expect(browser.defer).toHaveBeenCalled();
|
|
expect(browser.defer.callCount).toEqual(1);
|
|
browser.defer.mostRecentCall.args[0]();
|
|
expect(evalCount).toEqual(1);
|
|
});
|
|
|
|
|
|
it('should update immediatelly in test/mock mode', function(){
|
|
scope = angular.scope();
|
|
scope.$observe(function(){ evalCount++; });
|
|
expect(evalCount).toEqual(0);
|
|
scope.$service('$updateView')();
|
|
expect(evalCount).toEqual(1);
|
|
});
|
|
});
|