@@ -118,6 +118,110 @@ describe('<md-toolbar>', function() {
118
118
expect ( element . find ( 'md-toolbar' ) . length ) . toBe ( 0 ) ;
119
119
} ) ) ;
120
120
121
+ it ( 'works with ng-show' , inject ( function ( $$rAF ) {
122
+ var template =
123
+ '<div layout="column" style="height: 600px;">' +
124
+ ' <md-toolbar md-scroll-shrink="true" ng-show="shouldShowToolbar">test</md-toolbar>' +
125
+ ' <md-content flex><div style="height: 5000px;"></div></md-content>' +
126
+ '</div>' ;
127
+
128
+ // Build/append the element
129
+ build ( template ) ;
130
+ document . body . appendChild ( element [ 0 ] ) ;
131
+
132
+ // Flushing to get the actual height of toolbar
133
+ $$rAF . flush ( ) ;
134
+
135
+ //
136
+ // Initial tests
137
+ //
138
+
139
+ var toolbarStyles = getComputedStyle ( element . find ( 'md-toolbar' ) [ 0 ] ) ;
140
+ var contentStyles = getComputedStyle ( element . find ( 'md-content' ) [ 0 ] ) ;
141
+
142
+ // Should start out hidden because we have not set shouldShowToolbar
143
+ expect ( toolbarStyles . display ) . toBeTruthy ( ) ;
144
+ expect ( toolbarStyles . display ) . toEqual ( 'none' ) ;
145
+
146
+ // Expect the content to have a zero margin top
147
+ expect ( contentStyles . marginTop ) . toBeTruthy ( ) ;
148
+ expect ( contentStyles . marginTop ) . toEqual ( '0px' ) ;
149
+
150
+ //
151
+ // After showing toolbar tests
152
+ //
153
+
154
+ // Show the toolbar and ensure it is visible
155
+ pageScope . $apply ( 'shouldShowToolbar = true' ) ;
156
+ pageScope . $digest ( ) ;
157
+
158
+ toolbarStyles = getComputedStyle ( element . find ( 'md-toolbar' ) [ 0 ] ) ;
159
+ contentStyles = getComputedStyle ( element . find ( 'md-content' ) [ 0 ] ) ;
160
+
161
+ // Expect the toolbar to be visible
162
+ expect ( toolbarStyles . display ) . toBeTruthy ( ) ;
163
+ expect ( toolbarStyles . display ) . not . toEqual ( 'none' ) ;
164
+
165
+ // Expect the content to have a non-zero margin top (because updateToolbarHeight() was called)
166
+ expect ( contentStyles . marginTop ) . toBeTruthy ( ) ;
167
+ expect ( contentStyles . marginTop ) . not . toEqual ( '0px' ) ;
168
+
169
+ // Remove the element
170
+ document . body . removeChild ( element [ 0 ] ) ;
171
+ } ) ) ;
172
+
173
+ it ( 'works with ng-hide' , inject ( function ( $$rAF ) {
174
+ var template =
175
+ '<div layout="column" style="height: 600px;">' +
176
+ ' <md-toolbar md-scroll-shrink="true" ng-hide="shouldNotShowToolbar">test</md-toolbar>' +
177
+ ' <md-content flex><div style="height: 5000px;"></div></md-content>' +
178
+ '</div>' ;
179
+
180
+ // Build/append the element
181
+ build ( template ) ;
182
+ document . body . appendChild ( element [ 0 ] ) ;
183
+
184
+ // Flushing to get the actual height of toolbar
185
+ $$rAF . flush ( ) ;
186
+
187
+ //
188
+ // Initial tests
189
+ //
190
+
191
+ var toolbarStyles = getComputedStyle ( element . find ( 'md-toolbar' ) [ 0 ] ) ;
192
+ var contentStyles = getComputedStyle ( element . find ( 'md-content' ) [ 0 ] ) ;
193
+
194
+ // Should start out visible because we have not set shouldNotShowToolbar
195
+ expect ( toolbarStyles . display ) . toBeTruthy ( ) ;
196
+ expect ( toolbarStyles . display ) . not . toEqual ( 'none' ) ;
197
+
198
+ // Expect the content to have a non-zero margin top
199
+ expect ( contentStyles . marginTop ) . toBeTruthy ( ) ;
200
+ expect ( contentStyles . marginTop ) . not . toEqual ( '0px' ) ;
201
+
202
+ //
203
+ // After showing toolbar tests
204
+ //
205
+
206
+ // Show the toolbar and ensure it is hidden
207
+ pageScope . $apply ( 'shouldNotShowToolbar = true' ) ;
208
+ pageScope . $digest ( ) ;
209
+
210
+ toolbarStyles = getComputedStyle ( element . find ( 'md-toolbar' ) [ 0 ] ) ;
211
+ contentStyles = getComputedStyle ( element . find ( 'md-content' ) [ 0 ] ) ;
212
+
213
+ // Expect the toolbar to be hidden
214
+ expect ( toolbarStyles . display ) . toBeTruthy ( ) ;
215
+ expect ( toolbarStyles . display ) . toEqual ( 'none' ) ;
216
+
217
+ // Expect the content to have a zero margin top (because updateToolbarHeight() was called)
218
+ expect ( contentStyles . marginTop ) . toBeTruthy ( ) ;
219
+ expect ( contentStyles . marginTop ) . toEqual ( '0px' ) ;
220
+
221
+ // Remove the element
222
+ document . body . removeChild ( element [ 0 ] ) ;
223
+ } ) ) ;
224
+
121
225
// The toolbar is like a container component, so we want to make sure it works with ng-controller
122
226
it ( 'works with ng-controller' , inject ( function ( $exceptionHandler ) {
123
227
build (
0 commit comments