|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright Google LLC All Rights Reserved. |
| 4 | + * |
| 5 | + * Use of this source code is governed by an MIT-style license that can be |
| 6 | + * found in the LICENSE file at https://angular.io/license |
| 7 | + */ |
| 8 | +import {fakeAsync} from '@angular/core/testing'; |
| 9 | +import {NoopAnimationPlayer} from '../src/animations'; |
| 10 | +import {AnimationGroupPlayer} from '../src/players/animation_group_player'; |
| 11 | + |
| 12 | + |
| 13 | +describe('AnimationGroupPlayer', () => { |
| 14 | + it('should getPosition of an empty group', fakeAsync(() => { |
| 15 | + const players: NoopAnimationPlayer[] = []; |
| 16 | + const groupPlayer = new AnimationGroupPlayer(players); |
| 17 | + expect(groupPlayer.getPosition()).toBe(0); |
| 18 | + })); |
| 19 | + |
| 20 | + it('should getPosition of a single player in a group', fakeAsync(() => { |
| 21 | + const player = new NoopAnimationPlayer(5, 5); |
| 22 | + player.setPosition(0.2); |
| 23 | + const players = [player]; |
| 24 | + const groupPlayer = new AnimationGroupPlayer(players); |
| 25 | + expect(groupPlayer.getPosition()).toBe(0.2); |
| 26 | + })); |
| 27 | + |
| 28 | + it('should getPosition based on the longest player in the group', fakeAsync(() => { |
| 29 | + const longestPlayer = new NoopAnimationPlayer(5, 5); |
| 30 | + longestPlayer.setPosition(0.2); |
| 31 | + const players = [ |
| 32 | + new NoopAnimationPlayer(1, 4), |
| 33 | + new NoopAnimationPlayer(4, 1), |
| 34 | + new NoopAnimationPlayer(7, 0), |
| 35 | + longestPlayer, |
| 36 | + new NoopAnimationPlayer(1, 1), |
| 37 | + ]; |
| 38 | + const groupPlayer = new AnimationGroupPlayer(players); |
| 39 | + expect(groupPlayer.getPosition()).toBe(0.2); |
| 40 | + })); |
| 41 | +}); |
0 commit comments