Skip to content

Commit

Permalink
fix(platform-browser): update started state on reset
Browse files Browse the repository at this point in the history
This commit fixes the state of variable _started on call of reset method.

Resolves #18140
  • Loading branch information
iRealNirmal committed Apr 15, 2021
1 parent 5332a4a commit c5391cb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Expand Up @@ -104,6 +104,7 @@ export class RendererAnimationPlayer implements AnimationPlayer {

reset(): void {
this._command('reset');
this._started = false;
}

setPosition(p: number): void {
Expand Down
Expand Up @@ -104,5 +104,43 @@ import {el} from '../../testing/src/browser_util';
expect(finished).toBeTruthy();
expect(destroyed).toBeTruthy();
}));

it('should check status of start of play and reset', fakeAsync(() => {
@Component({
selector: 'ani-another-cmp',
template: '...',
})
class CmpAnother {
@ViewChild('target') public target: any;

constructor(public builder: AnimationBuilder) {}

build() {
const definition =
this.builder.build([style({opacity: 0}), animate(1000, style({opacity: 1}))]);

return definition.create(this.target);
}
}

TestBed.configureTestingModule({declarations: [CmpAnother]});

const fixture = TestBed.createComponent(CmpAnother);
const cmp = fixture.componentInstance;
fixture.detectChanges();

const player = cmp.build();

expect(player.hasStarted()).toBeFalsy();
flushMicrotasks();

player.play();
flushMicrotasks();
expect(player.hasStarted()).toBeTruthy();

player.reset();
flushMicrotasks();
expect(player.hasStarted()).toBeFalsy();
}));
});
}

0 comments on commit c5391cb

Please sign in to comment.