@@ -20,6 +20,7 @@ describe('ConnectedPositionStrategy', () => {
20
20
21
21
let originElement : HTMLElement ;
22
22
let overlayElement : HTMLElement ;
23
+ let overlayContainerElement : HTMLElement ;
23
24
let strategy : ConnectedPositionStrategy ;
24
25
let fakeElementRef : ElementRef ;
25
26
let fakeViewportRuler : FakeViewportRuler ;
@@ -34,17 +35,19 @@ describe('ConnectedPositionStrategy', () => {
34
35
35
36
// The origin and overlay elements need to be in the document body in order to have geometry.
36
37
originElement = createPositionedBlockElement ( ) ;
38
+ overlayContainerElement = createFixedElement ( ) ;
37
39
overlayElement = createPositionedBlockElement ( ) ;
38
40
document . body . appendChild ( originElement ) ;
39
- document . body . appendChild ( overlayElement ) ;
41
+ document . body . appendChild ( overlayContainerElement ) ;
42
+ overlayContainerElement . appendChild ( overlayElement ) ;
40
43
41
44
fakeElementRef = new FakeElementRef ( originElement ) ;
42
45
positionBuilder = new OverlayPositionBuilder ( new ViewportRuler ( ) ) ;
43
46
} ) ;
44
47
45
48
afterEach ( ( ) => {
46
49
document . body . removeChild ( originElement ) ;
47
- document . body . removeChild ( overlayElement ) ;
50
+ document . body . removeChild ( overlayContainerElement ) ;
48
51
49
52
// Reset the origin geometry after each test so we don't accidently keep state between tests.
50
53
originRect = null ;
@@ -359,6 +362,18 @@ function createPositionedBlockElement() {
359
362
return element ;
360
363
}
361
364
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
+
362
377
363
378
/** Fake implementation of ViewportRuler that just returns the previously given ClientRect. */
364
379
class FakeViewportRuler implements ViewportRuler {
0 commit comments