Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Commit

Permalink
chore(ngMock): rename $animate.process to $animate.flushNext()
Browse files Browse the repository at this point in the history
  • Loading branch information
matsko authored and mhevery committed Aug 3, 2013
1 parent 52a7c35 commit 85d705a
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 49 deletions.
2 changes: 1 addition & 1 deletion src/ngMock/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ angular.mock.animate = angular.module('mock.animate', ['ng'])
var animate = {
queue : [],
enabled : $delegate.enabled,
process : function(name) {
flushNext : function(name) {
var tick = animate.queue.shift();
expect(tick.method).toBe(name);
tick.fn();
Expand Down
12 changes: 6 additions & 6 deletions test/ng/directive/ngClassSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,27 +322,27 @@ describe('ngClass animations', function() {

$rootScope.val = 'one';
$rootScope.$digest();
$animate.process('addClass');
$animate.process('addClass');
$animate.flushNext('addClass');
$animate.flushNext('addClass');
$timeout.flush();
expect($animate.queue.length).toBe(0);

$rootScope.val = '';
$rootScope.$digest();
$animate.process('removeClass'); //only removeClass is called
$animate.flushNext('removeClass'); //only removeClass is called
expect($animate.queue.length).toBe(0);
$timeout.flush();

$rootScope.val = 'one';
$rootScope.$digest();
$animate.process('addClass');
$animate.flushNext('addClass');
$timeout.flush();
expect($animate.queue.length).toBe(0);

$rootScope.val = 'two';
$rootScope.$digest();
$animate.process('removeClass');
$animate.process('addClass');
$animate.flushNext('removeClass');
$animate.flushNext('addClass');
$timeout.flush();
expect($animate.queue.length).toBe(0);
}));
Expand Down
6 changes: 3 additions & 3 deletions test/ng/directive/ngIfSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('ngIf animations', function () {
$rootScope.$digest();
$scope.$apply('value = true');

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('Hi');

expect(element.children().length).toBe(1);
Expand All @@ -136,13 +136,13 @@ describe('ngIf animations', function () {
))($scope);
$scope.$apply('value = true');

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('Hi');

$scope.$apply('value = false');
expect(element.children().length).toBe(1);

item = $animate.process('leave').element;
item = $animate.flushNext('leave').element;
expect(item.text()).toBe('Hi');

expect(element.children().length).toBe(0);
Expand Down
12 changes: 6 additions & 6 deletions test/ng/directive/ngIncludeSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ describe('ngInclude animations', function() {
))($rootScope);
$rootScope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('data');
}));

Expand All @@ -404,13 +404,13 @@ describe('ngInclude animations', function() {
))($rootScope);
$rootScope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('data');

$rootScope.tpl = '';
$rootScope.$digest();

item = $animate.process('leave').element;
item = $animate.flushNext('leave').element;
expect(item.text()).toBe('data');
}));

Expand All @@ -427,14 +427,14 @@ describe('ngInclude animations', function() {
))($rootScope);
$rootScope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('one');

$rootScope.tpl = 'two';
$rootScope.$digest();

var itemA = $animate.process('leave').element;
var itemB = $animate.process('enter').element;
var itemA = $animate.flushNext('leave').element;
var itemB = $animate.flushNext('enter').element;
expect(itemA.attr('ng-include')).toBe('tpl');
expect(itemB.attr('ng-include')).toBe('tpl');
expect(itemA).not.toEqual(itemB);
Expand Down
24 changes: 12 additions & 12 deletions test/ng/directive/ngRepeatSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -907,13 +907,13 @@ describe('ngRepeat animations', function() {
$rootScope.items = ['1','2','3'];
$rootScope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('1');

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('2');

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('3');
}));

Expand All @@ -932,19 +932,19 @@ describe('ngRepeat animations', function() {
$rootScope.items = ['1','2','3'];
$rootScope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('1');

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('2');

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('3');

$rootScope.items = ['1','3'];
$rootScope.$digest();

item = $animate.process('leave').element;
item = $animate.flushNext('leave').element;
expect(item.text()).toBe('2');
}));

Expand All @@ -964,22 +964,22 @@ describe('ngRepeat animations', function() {
$rootScope.items = ['1','2','3'];
$rootScope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('1');

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('2');

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('3');

$rootScope.items = ['2','3','1'];
$rootScope.$digest();

item = $animate.process('move').element;
item = $animate.flushNext('move').element;
expect(item.text()).toBe('2');

item = $animate.process('move').element;
item = $animate.flushNext('move').element;
expect(item.text()).toBe('1');
}));

Expand Down
8 changes: 4 additions & 4 deletions test/ng/directive/ngShowHideSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ describe('ngShow / ngHide animations', function() {
))($scope);
$scope.$digest();

item = $animate.process('removeClass').element;
item = $animate.flushNext('removeClass').element;
expect(item.text()).toBe('data');
expect(item).toBeShown();

$scope.on = false;
$scope.$digest();

item = $animate.process('addClass').element;
item = $animate.flushNext('addClass').element;
expect(item.text()).toBe('data');
expect(item).toBeHidden();
}));
Expand All @@ -104,14 +104,14 @@ describe('ngShow / ngHide animations', function() {
))($scope);
$scope.$digest();

item = $animate.process('addClass').element;
item = $animate.flushNext('addClass').element;
expect(item.text()).toBe('datum');
expect(item).toBeHidden();

$scope.off = false;
$scope.$digest();

item = $animate.process('removeClass').element;
item = $animate.flushNext('removeClass').element;
expect(item.text()).toBe('datum');
expect(item).toBeShown();
}));
Expand Down
8 changes: 4 additions & 4 deletions test/ng/directive/ngSwitchSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ describe('ngSwitch animations', function() {
$scope.val = 'one';
$scope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('one');
}));

Expand All @@ -276,16 +276,16 @@ describe('ngSwitch animations', function() {
$scope.val = 'two';
$scope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('two');

$scope.val = 'three';
$scope.$digest();

item = $animate.process('leave').element;
item = $animate.flushNext('leave').element;
expect(item.text()).toBe('two');

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('three');
}));

Expand Down
26 changes: 13 additions & 13 deletions test/ngRoute/directive/ngViewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ describe('ngView animations', function() {
$location.path('/foo');
$rootScope.$digest();

var item = $animate.process('enter').element;
var item = $animate.flushNext('enter').element;
expect(item.text()).toBe('data');
}));

Expand All @@ -570,13 +570,13 @@ describe('ngView animations', function() {
$location.path('/foo');
$rootScope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('foo');

$location.path('/');
$rootScope.$digest();

item = $animate.process('leave').element;
item = $animate.flushNext('leave').element;
expect(item.text()).toBe('foo');
}));

Expand All @@ -590,15 +590,15 @@ describe('ngView animations', function() {
$location.path('/foo');
$rootScope.$digest();

item = $animate.process('enter').element;
item = $animate.flushNext('enter').element;
expect(item.text()).toBe('data');

$location.path('/bar');
$rootScope.$digest();

var itemA = $animate.process('leave').element;
var itemA = $animate.flushNext('leave').element;
expect(itemA).not.toEqual(itemB);
var itemB = $animate.process('enter').element;
var itemB = $animate.flushNext('enter').element;
}));
});

Expand Down Expand Up @@ -627,12 +627,12 @@ describe('ngView animations', function() {
$location.path('/foo');
$rootScope.$digest();

$animate.process('enter'); //ngView
$animate.flushNext('enter'); //ngView

$timeout.flush();

$animate.process('enter'); //repeat 1
$animate.process('enter'); //repeat 2
$animate.flushNext('enter'); //repeat 1
$animate.flushNext('enter'); //repeat 2

$timeout.flush();

Expand All @@ -641,16 +641,16 @@ describe('ngView animations', function() {
$location.path('/bar');
$rootScope.$digest();

$animate.process('leave'); //ngView old
$animate.flushNext('leave'); //ngView old
$timeout.flush();

$animate.process('enter'); //ngView new
$animate.flushNext('enter'); //ngView new
$timeout.flush();

expect(n(element.text())).toEqual(''); //this is midway during the animation

$animate.process('enter'); //ngRepeat 3
$animate.process('enter'); //ngRepeat 4
$animate.flushNext('enter'); //ngRepeat 3
$animate.flushNext('enter'); //ngRepeat 4

$timeout.flush();

Expand Down

0 comments on commit 85d705a

Please sign in to comment.