feat(platform-browser): add token marking which the type of animation module nearest in the injector tree (#23075)

PR Close #23075
This commit is contained in:
Joey Perrott
2018-03-29 16:32:23 -07:00
committed by Igor Minar
parent f958293205
commit b551f844e4
4 changed files with 47 additions and 6 deletions

View File

@ -8,9 +8,9 @@
import {AUTO_STYLE, AnimationEvent, AnimationOptions, AnimationPlayer, NoopAnimationPlayer, animate, animateChild, group, keyframes, query, state, style, transition, trigger, ɵPRE_STYLE as PRE_STYLE} from '@angular/animations';
import {AnimationDriver, ɵAnimationEngine, ɵNoopAnimationDriver as NoopAnimationDriver} from '@angular/animations/browser';
import {MockAnimationDriver, MockAnimationPlayer} from '@angular/animations/browser/testing';
import {ChangeDetectorRef, Component, HostBinding, HostListener, RendererFactory2, ViewChild} from '@angular/core';
import {ChangeDetectorRef, Component, HostBinding, HostListener, Inject, RendererFactory2, ViewChild} from '@angular/core';
import {ɵDomRendererFactory2} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {ANIMATION_MODULE_TYPE, BrowserAnimationsModule, NoopAnimationsModule} from '@angular/platform-browser/animations';
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
import {TestBed, fakeAsync, flushMicrotasks} from '../../testing';
@ -37,6 +37,34 @@ const DEFAULT_COMPONENT_ID = '1';
});
});
describe('animation modules', function() {
it('should hint at BrowserAnimationsModule being used', () => {
TestBed.resetTestingModule();
TestBed.configureTestingModule(
{declarations: [SharedAnimationCmp], imports: [BrowserAnimationsModule]});
const fixture = TestBed.createComponent(SharedAnimationCmp);
const cmp = fixture.componentInstance;
expect(cmp.animationType).toEqual('BrowserAnimations');
});
it('should hint at NoopAnimationsModule being used', () => {
TestBed.resetTestingModule();
TestBed.configureTestingModule(
{declarations: [SharedAnimationCmp], imports: [NoopAnimationsModule]});
const fixture = TestBed.createComponent(SharedAnimationCmp);
const cmp = fixture.componentInstance;
expect(cmp.animationType).toEqual('NoopAnimations');
});
});
@Component({template: '<p>template text</p>'})
class SharedAnimationCmp {
constructor(@Inject(ANIMATION_MODULE_TYPE) public animationType: 'NoopAnimations'|
'BrowserAnimations') {}
}
describe('fakeAsync testing', () => {
it('should only require one flushMicrotasks call to kick off animation callbacks',
fakeAsync(() => {