1- import  { inject ,  fakeAsync ,   flushMicrotasks ,   TestBed ,  async }  from  '@angular/core/testing' ; 
1+ import  { inject ,  TestBed ,  async }  from  '@angular/core/testing' ; 
22import  { NgModule ,  Component ,  ViewChild ,  ViewContainerRef }  from  '@angular/core' ; 
33import  { TemplatePortalDirective ,  PortalModule }  from  '../portal/portal-directives' ; 
44import  { TemplatePortal ,  ComponentPortal }  from  '../portal/portal' ; 
55import  { Overlay }  from  './overlay' ; 
66import  { OverlayContainer }  from  './overlay-container' ; 
7- import  { OverlayRef }  from  './overlay-ref' ; 
87import  { OverlayState }  from  './overlay-state' ; 
98import  { PositionStrategy }  from  './position/position-strategy' ; 
109import  { OverlayModule }  from  './overlay-directives' ; 
@@ -30,68 +29,43 @@ describe('Overlay', () => {
3029    TestBed . compileComponents ( ) ; 
3130  } ) ) ; 
3231
33-   beforeEach ( fakeAsync ( inject ( [ Overlay ] ,  ( o : Overlay )  =>  { 
32+   beforeEach ( inject ( [ Overlay ] ,  ( o : Overlay )  =>  { 
3433    overlay  =  o ; 
3534
3635    let  fixture  =  TestBed . createComponent ( TestComponentWithTemplatePortals ) ; 
3736    fixture . detectChanges ( ) ; 
3837    templatePortal  =  fixture . componentInstance . templatePortal ; 
3938    componentPortal  =  new  ComponentPortal ( PizzaMsg ,  fixture . componentInstance . viewContainerRef ) ; 
39+   } ) ) ; 
4040
41-     flushMicrotasks ( ) ; 
42-   } ) ) ) ; 
43- 
44-   it ( 'should load a component into an overlay' ,  fakeAsync ( ( )  =>  { 
45-     let  overlayRef : OverlayRef ; 
46- 
47-     overlay . create ( ) . then ( ref  =>  { 
48-       overlayRef  =  ref ; 
49-       overlayRef . attach ( componentPortal ) ; 
50-     } ) ; 
51- 
52-     flushMicrotasks ( ) ; 
41+   it ( 'should load a component into an overlay' ,  ( )  =>  { 
42+     let  overlayRef  =  overlay . create ( ) ; 
43+     overlayRef . attach ( componentPortal ) ; 
5344
5445    expect ( overlayContainerElement . textContent ) . toContain ( 'Pizza' ) ; 
5546
5647    overlayRef . dispose ( ) ; 
5748    expect ( overlayContainerElement . childNodes . length ) . toBe ( 0 ) ; 
5849    expect ( overlayContainerElement . textContent ) . toBe ( '' ) ; 
59-   } ) ) ; 
60- 
61-   it ( 'should load a template portal into an overlay' ,  fakeAsync ( ( )  =>  { 
62-     let  overlayRef : OverlayRef ; 
63- 
64-     overlay . create ( ) . then ( ref  =>  { 
65-       overlayRef  =  ref ; 
66-       overlayRef . attach ( templatePortal ) ; 
67-     } ) ; 
50+   } ) ; 
6851
69-     flushMicrotasks ( ) ; 
52+   it ( 'should load a template portal into an overlay' ,  ( )  =>  { 
53+     let  overlayRef  =  overlay . create ( ) ; 
54+     overlayRef . attach ( templatePortal ) ; 
7055
7156    expect ( overlayContainerElement . textContent ) . toContain ( 'Cake' ) ; 
7257
7358    overlayRef . dispose ( ) ; 
7459    expect ( overlayContainerElement . childNodes . length ) . toBe ( 0 ) ; 
7560    expect ( overlayContainerElement . textContent ) . toBe ( '' ) ; 
76-   } ) ) ; 
77- 
78-   it ( 'should open multiple overlays' ,  fakeAsync ( ( )  =>  { 
79-     let  pizzaOverlayRef : OverlayRef ; 
80-     let  cakeOverlayRef : OverlayRef ; 
81- 
82-     overlay . create ( ) . then ( ref  =>  { 
83-       pizzaOverlayRef  =  ref ; 
84-       pizzaOverlayRef . attach ( componentPortal ) ; 
85-     } ) ; 
86- 
87-     flushMicrotasks ( ) ; 
61+   } ) ; 
8862
89-     overlay . create ( ) . then ( ref  =>  { 
90-       cakeOverlayRef  =  ref ; 
91-       cakeOverlayRef . attach ( templatePortal ) ; 
92-     } ) ; 
63+   it ( 'should open multiple overlays' ,  ( )  =>  { 
64+     let  pizzaOverlayRef  =  overlay . create ( ) ; 
65+     pizzaOverlayRef . attach ( componentPortal ) ; 
9366
94-     flushMicrotasks ( ) ; 
67+     let  cakeOverlayRef  =  overlay . create ( ) ; 
68+     cakeOverlayRef . attach ( templatePortal ) ; 
9569
9670    expect ( overlayContainerElement . childNodes . length ) . toBe ( 2 ) ; 
9771    expect ( overlayContainerElement . textContent ) . toContain ( 'Pizza' ) ; 
@@ -104,7 +78,7 @@ describe('Overlay', () => {
10478    cakeOverlayRef . dispose ( ) ; 
10579    expect ( overlayContainerElement . childNodes . length ) . toBe ( 0 ) ; 
10680    expect ( overlayContainerElement . textContent ) . toBe ( '' ) ; 
107-   } ) ) ; 
81+   } ) ; 
10882
10983  describe ( 'applyState' ,  ( )  =>  { 
11084    let  state : OverlayState ; 
@@ -113,17 +87,13 @@ describe('Overlay', () => {
11387      state  =  new  OverlayState ( ) ; 
11488    } ) ; 
11589
116-     it ( 'should apply the positioning strategy' ,  fakeAsync ( ( )  =>  { 
90+     it ( 'should apply the positioning strategy' ,  ( )  =>  { 
11791      state . positionStrategy  =  new  FakePositionStrategy ( ) ; 
11892
119-       overlay . create ( state ) . then ( ref  =>  { 
120-         ref . attach ( componentPortal ) ; 
121-       } ) ; 
122- 
123-       flushMicrotasks ( ) ; 
93+       overlay . create ( state ) . attach ( componentPortal ) ; 
12494
12595      expect ( overlayContainerElement . querySelectorAll ( '.fake-positioned' ) . length ) . toBe ( 1 ) ; 
126-     } ) ) ; 
96+     } ) ; 
12797  } ) ; 
12898} ) ; 
12999
0 commit comments