@@ -148,19 +148,19 @@ describe('MdMenu', () => {
148148
149149 fixture . componentInstance . trigger . openMenu ( ) ;
150150 fixture . detectChanges ( ) ;
151- const overlayPane = overlayContainerElement . children [ 0 ] as HTMLElement ;
151+ const overlayPane = getOverlayPane ( ) ;
152152 const triggerRect = trigger . getBoundingClientRect ( ) ;
153153 const overlayRect = overlayPane . getBoundingClientRect ( ) ;
154154
155155 // In "before" position, the right sides of the overlay and the origin are aligned.
156156 // To find the overlay left, subtract the menu width from the origin's right side.
157157 const expectedLeft = triggerRect . right - overlayRect . width ;
158- expect ( overlayRect . left )
158+ expect ( Math . round ( overlayRect . left ) )
159159 . toBe ( Math . round ( expectedLeft ) ,
160160 `Expected menu to open in "before" position if "after" position wouldn't fit.` ) ;
161161
162162 // The y-position of the overlay should be unaffected, as it can already fit vertically
163- expect ( overlayRect . top )
163+ expect ( Math . round ( overlayRect . top ) )
164164 . toBe ( Math . round ( triggerRect . top ) ,
165165 `Expected menu top position to be unchanged if it can fit in the viewport.` ) ;
166166 } ) ;
@@ -177,19 +177,19 @@ describe('MdMenu', () => {
177177
178178 fixture . componentInstance . trigger . openMenu ( ) ;
179179 fixture . detectChanges ( ) ;
180- const overlayPane = overlayContainerElement . children [ 0 ] as HTMLElement ;
180+ const overlayPane = getOverlayPane ( ) ;
181181 const triggerRect = trigger . getBoundingClientRect ( ) ;
182182 const overlayRect = overlayPane . getBoundingClientRect ( ) ;
183183
184184 // In "above" position, the bottom edges of the overlay and the origin are aligned.
185185 // To find the overlay top, subtract the menu height from the origin's bottom edge.
186186 const expectedTop = triggerRect . bottom - overlayRect . height ;
187- expect ( overlayRect . top )
187+ expect ( Math . round ( overlayRect . top ) )
188188 . toBe ( Math . round ( expectedTop ) ,
189189 `Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
190190
191191 // The x-position of the overlay should be unaffected, as it can already fit horizontally
192- expect ( overlayRect . left )
192+ expect ( Math . round ( overlayRect . left ) )
193193 . toBe ( Math . round ( triggerRect . left ) ,
194194 `Expected menu x position to be unchanged if it can fit in the viewport.` ) ;
195195 } ) ;
@@ -207,18 +207,18 @@ describe('MdMenu', () => {
207207
208208 fixture . componentInstance . trigger . openMenu ( ) ;
209209 fixture . detectChanges ( ) ;
210- const overlayPane = overlayContainerElement . children [ 0 ] as HTMLElement ;
210+ const overlayPane = getOverlayPane ( ) ;
211211 const triggerRect = trigger . getBoundingClientRect ( ) ;
212212 const overlayRect = overlayPane . getBoundingClientRect ( ) ;
213213
214214 const expectedLeft = triggerRect . right - overlayRect . width ;
215215 const expectedTop = triggerRect . bottom - overlayRect . height ;
216216
217- expect ( overlayRect . left )
217+ expect ( Math . round ( overlayRect . left ) )
218218 . toBe ( Math . round ( expectedLeft ) ,
219219 `Expected menu to open in "before" position if "after" position wouldn't fit.` ) ;
220220
221- expect ( overlayRect . top )
221+ expect ( Math . round ( overlayRect . top ) )
222222 . toBe ( Math . round ( expectedTop ) ,
223223 `Expected menu to open in "above" position if "below" position wouldn't fit.` ) ;
224224 } ) ;
@@ -230,23 +230,28 @@ describe('MdMenu', () => {
230230
231231 fixture . componentInstance . trigger . openMenu ( ) ;
232232 fixture . detectChanges ( ) ;
233- const overlayPane = overlayContainerElement . children [ 0 ] as HTMLElement ;
233+ const overlayPane = getOverlayPane ( ) ;
234234 const triggerRect = trigger . getBoundingClientRect ( ) ;
235235 const overlayRect = overlayPane . getBoundingClientRect ( ) ;
236236
237237 // As designated "before" position won't fit on screen, the menu should fall back
238238 // to "after" mode, where the left sides of the overlay and trigger are aligned.
239- expect ( overlayRect . left )
239+ expect ( Math . round ( overlayRect . left ) )
240240 . toBe ( Math . round ( triggerRect . left ) ,
241241 `Expected menu to open in "after" position if "before" position wouldn't fit.` ) ;
242242
243243 // As designated "above" position won't fit on screen, the menu should fall back
244244 // to "below" mode, where the top edges of the overlay and trigger are aligned.
245- expect ( overlayRect . top )
245+ expect ( Math . round ( overlayRect . top ) )
246246 . toBe ( Math . round ( triggerRect . top ) ,
247247 `Expected menu to open in "below" position if "above" position wouldn't fit.` ) ;
248248 } ) ;
249249
250+ function getOverlayPane ( ) : HTMLElement {
251+ let pane = overlayContainerElement . children [ 0 ] as HTMLElement ;
252+ pane . style . position = 'absolute' ;
253+ return pane ;
254+ }
250255 } ) ;
251256
252257 describe ( 'animations' , ( ) => {
0 commit comments