From c0cc6eeca170f1bee782ae21a2eebcacc49c83e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matias=20Niemel=C3=A4?= Date: Wed, 11 Oct 2017 14:13:03 -0700 Subject: [PATCH] test(animations): ensure :enter callbacks fire on container insertion (#19674) PR Close #19674 --- .../animation/animation_integration_spec.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/core/test/animation/animation_integration_spec.ts b/packages/core/test/animation/animation_integration_spec.ts index 86e76e40d0..9b27d99efd 100644 --- a/packages/core/test/animation/animation_integration_spec.ts +++ b/packages/core/test/animation/animation_integration_spec.ts @@ -340,6 +340,42 @@ export function main() { expect(completed).toBe(true); })); + it('should always fire inner callbacks even if no animation is fired when a view is inserted', + fakeAsync(() => { + @Component({ + selector: 'if-cmp', + template: ` +
+
+
+ `, + animations: [ + trigger('myAnimation', []), + ] + }) + class Cmp { + exp: any = false; + log: string[] = []; + track(event: any) { this.log.push(`${event.triggerName}-${event.phaseName}`); } + } + + TestBed.configureTestingModule({declarations: [Cmp]}); + + const engine = TestBed.get(ɵAnimationEngine); + const fixture = TestBed.createComponent(Cmp); + const cmp = fixture.componentInstance; + fixture.detectChanges(); + flushMicrotasks(); + + expect(cmp.log).toEqual([]); + + cmp.exp = true; + fixture.detectChanges(); + flushMicrotasks(); + + expect(cmp.log).toEqual(['myAnimation-start', 'myAnimation-done']); + })); + it('should only turn a view removal as into `void` state transition', () => { @Component({ selector: 'if-cmp',