@@ -10,7 +10,6 @@ import {CommonModule} from '@angular/common';
1010import { ComponentFixture , TestBed , inject } from '@angular/core/testing' ;
1111import {
1212 MatchMedia ,
13- CoreModule ,
1413 MockMatchMedia ,
1514 MockMatchMediaProvider ,
1615 MediaObserver ,
@@ -22,7 +21,7 @@ import {customMatchers, expect, NgMatchers} from '../../utils/testing/custom-mat
2221import {
2322 makeCreateTestComponent , expectNativeEl , queryFor
2423} from '../../utils/testing/helpers' ;
25- import { DefaultShowHideDirective } from './show-hide ' ;
24+ import { FlexLayoutModule } from '../../module ' ;
2625
2726
2827describe ( 'hide directive' , ( ) => {
@@ -59,8 +58,8 @@ describe('hide directive', () => {
5958
6059 // Configure testbed to prepare services
6160 TestBed . configureTestingModule ( {
62- imports : [ CommonModule , CoreModule ] ,
63- declarations : [ TestHideComponent , DefaultShowHideDirective ] ,
61+ imports : [ CommonModule , FlexLayoutModule ] ,
62+ declarations : [ TestHideComponent ] ,
6463 providers : [
6564 MockMatchMediaProvider ,
6665 { provide : SERVER_TOKEN , useValue : true } ,
@@ -111,7 +110,12 @@ describe('hide directive', () => {
111110 expectNativeEl ( fixture , { isHidden : false } ) . not . toHaveStyle ( { 'display' : 'none' } , styler ) ;
112111 } ) ;
113112
114-
113+ it ( 'should use "flex" display style when the element also has an fxLayoutAlign' , ( ) => {
114+ createTestComponent ( `<div fxLayout fxLayoutAlign="start center" fxHide.xs></div>` ) ;
115+ expectNativeEl ( fixture ) . not . toHaveStyle ( { 'display' : 'none' } , styler ) ;
116+ matchMedia . activate ( 'xs' ) ;
117+ expectNativeEl ( fixture ) . toHaveStyle ( { 'display' : 'none' } , styler ) ;
118+ } ) ;
115119 } ) ;
116120
117121 describe ( 'with responsive features' , ( ) => {
@@ -257,6 +261,22 @@ describe('hide directive', () => {
257261 expectNativeEl ( fixture ) . toHaveStyle ( { 'display' : 'inline-block' } , styler ) ;
258262 } ) ;
259263
264+ it ( 'should support fxHide and fxLayout' , ( ) => {
265+ createTestComponent ( `
266+ <div fxLayout [fxHide.xs]="true">
267+ This content to be shown ONLY when gt-sm
268+ </div>
269+ ` ) ;
270+ matchMedia . activate ( 'xs' ) ;
271+ expectNativeEl ( fixture ) . toHaveStyle ( { 'display' : 'none' } , styler ) ;
272+
273+ matchMedia . activate ( 'sm' ) ;
274+ expectNativeEl ( fixture ) . not . toHaveStyle ( { 'display' : 'none' } , styler ) ;
275+
276+ matchMedia . activate ( 'xs' ) ;
277+ expectNativeEl ( fixture ) . toHaveStyle ( { 'display' : 'none' } , styler ) ;
278+ } ) ;
279+
260280} ) ;
261281
262282
0 commit comments