@@ -564,7 +564,7 @@ describe('MatDrawerContainer', () => {
564
564
fixture . detectChanges ( ) ;
565
565
tick ( ) ;
566
566
567
- expect ( parseInt ( contentElement . style . marginLeft ) ) . toBeLessThan ( initialMargin ) ;
567
+ expect ( contentElement . style . marginLeft ) . toBe ( '' ) ;
568
568
} ) ) ;
569
569
570
570
it ( 'should recalculate the margin if the drawer mode is changed' , fakeAsync ( ( ) => {
@@ -584,7 +584,7 @@ describe('MatDrawerContainer', () => {
584
584
fixture . componentInstance . mode = 'over' ;
585
585
fixture . detectChanges ( ) ;
586
586
587
- expect ( parseInt ( contentElement . style . marginLeft ) ) . toBeLessThan ( initialMargin ) ;
587
+ expect ( contentElement . style . marginLeft ) . toBe ( '' ) ;
588
588
} ) ) ;
589
589
590
590
it ( 'should recalculate the margin if the direction has changed' , fakeAsync ( ( ) => {
@@ -604,7 +604,7 @@ describe('MatDrawerContainer', () => {
604
604
fixture . componentInstance . direction = 'rtl' ;
605
605
fixture . detectChanges ( ) ;
606
606
607
- expect ( parseInt ( contentElement . style . marginLeft ) ) . toBe ( 0 ) ;
607
+ expect ( contentElement . style . marginLeft ) . toBe ( '' ) ;
608
608
expect ( parseInt ( contentElement . style . marginRight ) ) . toBe ( margin ) ;
609
609
} ) ) ;
610
610
@@ -651,6 +651,32 @@ describe('MatDrawerContainer', () => {
651
651
discardPeriodicTasks ( ) ;
652
652
} ) ) ;
653
653
654
+ it ( 'should not set a style property if it would be zero' , fakeAsync ( ( ) => {
655
+ const fixture = TestBed . createComponent ( AutosizeDrawer ) ;
656
+ fixture . detectChanges ( ) ;
657
+
658
+ const content = fixture . debugElement . nativeElement . querySelector ( '.mat-drawer-content' ) ;
659
+ expect ( content . style . marginLeft ) . toBe ( '' , 'Margin should be omitted when drawer is closed' ) ;
660
+
661
+ // Open the drawer and resolve the open animation.
662
+ fixture . componentInstance . drawer . open ( ) ;
663
+ fixture . detectChanges ( ) ;
664
+ tick ( ) ;
665
+ fixture . detectChanges ( ) ;
666
+
667
+ expect ( content . style . marginLeft ) . not . toBe ( '' , 'Margin should be present when drawer is open' ) ;
668
+
669
+ // Close the drawer and resolve the close animation.
670
+ fixture . componentInstance . drawer . close ( ) ;
671
+ fixture . detectChanges ( ) ;
672
+ tick ( ) ;
673
+ fixture . detectChanges ( ) ;
674
+
675
+ expect ( content . style . marginLeft ) . toBe ( '' , 'Margin should be removed after drawer close.' ) ;
676
+
677
+ discardPeriodicTasks ( ) ;
678
+ } ) ) ;
679
+
654
680
it ( 'should be able to toggle whether the container has a backdrop' , fakeAsync ( ( ) => {
655
681
const fixture = TestBed . createComponent ( BasicTestApp ) ;
656
682
fixture . detectChanges ( ) ;
0 commit comments