@@ -10,7 +10,6 @@ import {CommonModule} from '@angular/common';
10
10
import { ComponentFixture , TestBed , inject } from '@angular/core/testing' ;
11
11
import {
12
12
MatchMedia ,
13
- CoreModule ,
14
13
MockMatchMedia ,
15
14
MockMatchMediaProvider ,
16
15
MediaObserver ,
@@ -22,7 +21,7 @@ import {customMatchers, expect, NgMatchers} from '../../utils/testing/custom-mat
22
21
import {
23
22
makeCreateTestComponent , expectNativeEl , queryFor
24
23
} from '../../utils/testing/helpers' ;
25
- import { DefaultShowHideDirective } from './show-hide ' ;
24
+ import { FlexLayoutModule } from '../../module ' ;
26
25
27
26
28
27
describe ( 'hide directive' , ( ) => {
@@ -59,8 +58,8 @@ describe('hide directive', () => {
59
58
60
59
// Configure testbed to prepare services
61
60
TestBed . configureTestingModule ( {
62
- imports : [ CommonModule , CoreModule ] ,
63
- declarations : [ TestHideComponent , DefaultShowHideDirective ] ,
61
+ imports : [ CommonModule , FlexLayoutModule ] ,
62
+ declarations : [ TestHideComponent ] ,
64
63
providers : [
65
64
MockMatchMediaProvider ,
66
65
{ provide : SERVER_TOKEN , useValue : true } ,
@@ -111,7 +110,12 @@ describe('hide directive', () => {
111
110
expectNativeEl ( fixture , { isHidden : false } ) . not . toHaveStyle ( { 'display' : 'none' } , styler ) ;
112
111
} ) ;
113
112
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
+ } ) ;
115
119
} ) ;
116
120
117
121
describe ( 'with responsive features' , ( ) => {
@@ -257,6 +261,22 @@ describe('hide directive', () => {
257
261
expectNativeEl ( fixture ) . toHaveStyle ( { 'display' : 'inline-block' } , styler ) ;
258
262
} ) ;
259
263
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
+
260
280
} ) ;
261
281
262
282
0 commit comments