@@ -11,8 +11,8 @@ describe('MatExpansionPanel', () => {
1111 beforeEach ( async ( ( ) => {
1212 TestBed . configureTestingModule ( {
1313 imports : [
14+ MatExpansionModule ,
1415 NoopAnimationsModule ,
15- MatExpansionModule
1616 ] ,
1717 declarations : [
1818 PanelWithContent ,
@@ -44,8 +44,9 @@ describe('MatExpansionPanel', () => {
4444 } ) ) ;
4545
4646 it ( 'should be able to render panel content lazily' , fakeAsync ( ( ) => {
47- let fixture = TestBed . createComponent ( LazyPanelWithContent ) ;
48- let content = fixture . debugElement . query ( By . css ( '.mat-expansion-panel-content' ) ) . nativeElement ;
47+ const fixture = TestBed . createComponent ( LazyPanelWithContent ) ;
48+ const content = fixture . debugElement . query (
49+ By . css ( '.mat-expansion-panel-content' ) ) . nativeElement ;
4950 fixture . detectChanges ( ) ;
5051
5152 expect ( content . textContent . trim ( ) ) . toBe ( '' , 'Expected content element to be empty.' ) ;
@@ -58,8 +59,9 @@ describe('MatExpansionPanel', () => {
5859 } ) ) ;
5960
6061 it ( 'should render the content for a lazy-loaded panel that is opened on init' , fakeAsync ( ( ) => {
61- let fixture = TestBed . createComponent ( LazyPanelOpenOnLoad ) ;
62- let content = fixture . debugElement . query ( By . css ( '.mat-expansion-panel-content' ) ) . nativeElement ;
62+ const fixture = TestBed . createComponent ( LazyPanelOpenOnLoad ) ;
63+ const content = fixture . debugElement . query (
64+ By . css ( '.mat-expansion-panel-content' ) ) . nativeElement ;
6365 fixture . detectChanges ( ) ;
6466
6567 expect ( content . textContent . trim ( ) )
@@ -161,10 +163,10 @@ describe('MatExpansionPanel', () => {
161163 } ) ) ;
162164
163165 it ( 'should not override the panel margin if it is not inside an accordion' , fakeAsync ( ( ) => {
164- let fixture = TestBed . createComponent ( PanelWithCustomMargin ) ;
166+ const fixture = TestBed . createComponent ( PanelWithCustomMargin ) ;
165167 fixture . detectChanges ( ) ;
166168
167- let panel = fixture . debugElement . query ( By . css ( 'mat-expansion-panel' ) ) ;
169+ const panel = fixture . debugElement . query ( By . css ( 'mat-expansion-panel' ) ) ;
168170 let styles = getComputedStyle ( panel . nativeElement ) ;
169171
170172 expect ( panel . componentInstance . _hasSpacing ( ) ) . toBe ( false ) ;
@@ -221,7 +223,7 @@ describe('MatExpansionPanel', () => {
221223 } ) ) ;
222224
223225 it ( 'should make sure accordion item runs ngOnDestroy when expansion panel is destroyed' , ( ) => {
224- let fixture = TestBed . createComponent ( PanelWithContentInNgIf ) ;
226+ const fixture = TestBed . createComponent ( PanelWithContentInNgIf ) ;
225227 fixture . detectChanges ( ) ;
226228 let destroyedOk = false ;
227229 fixture . componentInstance . panel . destroyed . subscribe ( ( ) => destroyedOk = true ) ;
@@ -264,6 +266,27 @@ describe('MatExpansionPanel', () => {
264266 'Expected class to be added after the animation has finished' ) ;
265267 } ) ) ;
266268
269+ it ( 'should emit events for body expanding and collapsing animations' , fakeAsync ( ( ) => {
270+ const fixture = TestBed . createComponent ( PanelWithContent ) ;
271+ fixture . detectChanges ( ) ;
272+ let afterExpand = 0 ;
273+ let afterCollapse = 0 ;
274+ fixture . componentInstance . panel . afterExpand . subscribe ( ( ) => afterExpand ++ ) ;
275+ fixture . componentInstance . panel . afterCollapse . subscribe ( ( ) => afterCollapse ++ ) ;
276+
277+ fixture . componentInstance . expanded = true ;
278+ fixture . detectChanges ( ) ;
279+ flush ( ) ;
280+ expect ( afterExpand ) . toBe ( 1 ) ;
281+ expect ( afterCollapse ) . toBe ( 0 ) ;
282+
283+ fixture . componentInstance . expanded = false ;
284+ fixture . detectChanges ( ) ;
285+ flush ( ) ;
286+ expect ( afterExpand ) . toBe ( 1 ) ;
287+ expect ( afterCollapse ) . toBe ( 1 ) ;
288+ } ) ) ;
289+
267290 describe ( 'disabled state' , ( ) => {
268291 let fixture : ComponentFixture < PanelWithContent > ;
269292 let panel : HTMLElement ;
@@ -373,7 +396,7 @@ class PanelWithContentInNgIf {
373396 </mat-expansion-panel>`
374397} )
375398class PanelWithCustomMargin {
376- expanded : boolean = false ;
399+ expanded = false ;
377400}
378401
379402@Component ( {
0 commit comments