@@ -564,7 +564,7 @@ describe('MatDrawerContainer', () => {
564564 fixture . detectChanges ( ) ;
565565 tick ( ) ;
566566
567- expect ( parseInt ( contentElement . style . marginLeft ) ) . toBeLessThan ( initialMargin ) ;
567+ expect ( contentElement . style . marginLeft ) . toBe ( '' ) ;
568568 } ) ) ;
569569
570570 it ( 'should recalculate the margin if the drawer mode is changed' , fakeAsync ( ( ) => {
@@ -584,7 +584,7 @@ describe('MatDrawerContainer', () => {
584584 fixture . componentInstance . mode = 'over' ;
585585 fixture . detectChanges ( ) ;
586586
587- expect ( parseInt ( contentElement . style . marginLeft ) ) . toBeLessThan ( initialMargin ) ;
587+ expect ( contentElement . style . marginLeft ) . toBe ( '' ) ;
588588 } ) ) ;
589589
590590 it ( 'should recalculate the margin if the direction has changed' , fakeAsync ( ( ) => {
@@ -604,7 +604,7 @@ describe('MatDrawerContainer', () => {
604604 fixture . componentInstance . direction = 'rtl' ;
605605 fixture . detectChanges ( ) ;
606606
607- expect ( parseInt ( contentElement . style . marginLeft ) ) . toBe ( 0 ) ;
607+ expect ( contentElement . style . marginLeft ) . toBe ( '' ) ;
608608 expect ( parseInt ( contentElement . style . marginRight ) ) . toBe ( margin ) ;
609609 } ) ) ;
610610
@@ -651,6 +651,32 @@ describe('MatDrawerContainer', () => {
651651 discardPeriodicTasks ( ) ;
652652 } ) ) ;
653653
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+
654680 it ( 'should be able to toggle whether the container has a backdrop' , fakeAsync ( ( ) => {
655681 const fixture = TestBed . createComponent ( BasicTestApp ) ;
656682 fixture . detectChanges ( ) ;
0 commit comments