@@ -20,6 +20,7 @@ describe('ConnectedPositionStrategy', () => {
2020
2121 let originElement : HTMLElement ;
2222 let overlayElement : HTMLElement ;
23+ let overlayContainerElement : HTMLElement ;
2324 let strategy : ConnectedPositionStrategy ;
2425 let fakeElementRef : ElementRef ;
2526 let fakeViewportRuler : FakeViewportRuler ;
@@ -34,17 +35,19 @@ describe('ConnectedPositionStrategy', () => {
3435
3536 // The origin and overlay elements need to be in the document body in order to have geometry.
3637 originElement = createPositionedBlockElement ( ) ;
38+ overlayContainerElement = createFixedElement ( ) ;
3739 overlayElement = createPositionedBlockElement ( ) ;
3840 document . body . appendChild ( originElement ) ;
39- document . body . appendChild ( overlayElement ) ;
41+ document . body . appendChild ( overlayContainerElement ) ;
42+ overlayContainerElement . appendChild ( overlayElement ) ;
4043
4144 fakeElementRef = new FakeElementRef ( originElement ) ;
4245 positionBuilder = new OverlayPositionBuilder ( new ViewportRuler ( ) ) ;
4346 } ) ;
4447
4548 afterEach ( ( ) => {
4649 document . body . removeChild ( originElement ) ;
47- document . body . removeChild ( overlayElement ) ;
50+ document . body . removeChild ( overlayContainerElement ) ;
4851
4952 // Reset the origin geometry after each test so we don't accidently keep state between tests.
5053 originRect = null ;
@@ -359,6 +362,18 @@ function createPositionedBlockElement() {
359362 return element ;
360363}
361364
365+ /** Creates an position: fixed element that spans the screen size. */
366+ function createFixedElement ( ) {
367+ let element = document . createElement ( 'div' ) ;
368+ element . style . position = 'fixed' ;
369+ element . style . top = '0' ;
370+ element . style . left = '0' ;
371+ element . style . width = `100%` ;
372+ element . style . height = `100%` ;
373+ element . style . zIndex = '100' ;
374+ return element ;
375+ }
376+
362377
363378/** Fake implementation of ViewportRuler that just returns the previously given ClientRect. */
364379class FakeViewportRuler implements ViewportRuler {
0 commit comments