@@ -2079,6 +2079,100 @@ describe('FlexibleConnectedPositionStrategy', () => {
20792079 expect ( boundingBoxStyle . maxHeight ) . toBeFalsy ( ) ;
20802080 } ) ;
20812081
2082+ it ( 'should collapse the overlay vertically if overlay is outside of viewport, but taller ' +
2083+ 'than the minHeight' , ( ) => {
2084+ const bottomOffset = OVERLAY_HEIGHT / 2 ;
2085+ originElement . style . bottom = `${ bottomOffset } px` ;
2086+ originElement . style . left = '50%' ;
2087+ originElement . style . position = 'fixed' ;
2088+
2089+ positionStrategy
2090+ . withFlexibleDimensions ( )
2091+ . withPush ( true )
2092+ . withPositions ( [ {
2093+ overlayY : 'top' ,
2094+ overlayX : 'start' ,
2095+ originY : 'bottom' ,
2096+ originX : 'start' ,
2097+ } ] ) ;
2098+
2099+ attachOverlay ( { positionStrategy, minHeight : bottomOffset - 1 } ) ;
2100+ const overlayRect = overlayRef . overlayElement . getBoundingClientRect ( ) ;
2101+
2102+ expect ( Math . floor ( overlayRect . height ) ) . toBe ( bottomOffset ) ;
2103+ } ) ;
2104+
2105+ it ( 'should collapse the overlay vertically if overlay is outside of viewport, but taller ' +
2106+ 'than the minHeight that is set as a pixel string' , ( ) => {
2107+ const bottomOffset = OVERLAY_HEIGHT / 2 ;
2108+ originElement . style . bottom = `${ bottomOffset } px` ;
2109+ originElement . style . left = '50%' ;
2110+ originElement . style . position = 'fixed' ;
2111+
2112+ positionStrategy
2113+ . withFlexibleDimensions ( )
2114+ . withPush ( true )
2115+ . withPositions ( [ {
2116+ overlayY : 'top' ,
2117+ overlayX : 'start' ,
2118+ originY : 'bottom' ,
2119+ originX : 'start' ,
2120+ } ] ) ;
2121+
2122+ attachOverlay ( { positionStrategy, minHeight : `${ bottomOffset - 1 } px` } ) ;
2123+ const overlayRect = overlayRef . overlayElement . getBoundingClientRect ( ) ;
2124+
2125+ expect ( Math . floor ( overlayRect . height ) ) . toBe ( bottomOffset ) ;
2126+ } ) ;
2127+
2128+ it ( 'should collapse the overlay horizontally if overlay is outside of viewport, but wider ' +
2129+ 'than the minWidth' , ( ) => {
2130+ const rightOffset = OVERLAY_WIDTH / 2 ;
2131+ originElement . style . top = '50%' ;
2132+ originElement . style . right = `${ rightOffset } px` ;
2133+ originElement . style . position = 'fixed' ;
2134+
2135+ positionStrategy
2136+ . withFlexibleDimensions ( )
2137+ . withPush ( true )
2138+ . withPositions ( [ {
2139+ overlayY : 'top' ,
2140+ overlayX : 'start' ,
2141+ originY : 'top' ,
2142+ originX : 'end' ,
2143+ } ] ) ;
2144+
2145+ attachOverlay ( { positionStrategy, minWidth : rightOffset } ) ;
2146+ const overlayRect = overlayRef . overlayElement . getBoundingClientRect ( ) ;
2147+
2148+ expect ( Math . floor ( overlayRect . width ) ) . toBe ( rightOffset ) ;
2149+ } ) ;
2150+
2151+ it ( 'should collapse the overlay horizontally if overlay is outside of viewport, but wider ' +
2152+ 'than the minWidth that is set as a pixel string' , ( ) => {
2153+ const rightOffset = OVERLAY_WIDTH / 2 ;
2154+ originElement . style . top = '50%' ;
2155+ originElement . style . right = `${ rightOffset } px` ;
2156+ originElement . style . position = 'fixed' ;
2157+
2158+ positionStrategy
2159+ . withFlexibleDimensions ( )
2160+ . withPush ( true )
2161+ . withPositions ( [ {
2162+ overlayY : 'top' ,
2163+ overlayX : 'start' ,
2164+ originY : 'top' ,
2165+ originX : 'end' ,
2166+ } ] ) ;
2167+
2168+ attachOverlay ( { positionStrategy, minWidth : `${ rightOffset } px` } ) ;
2169+ const overlayRect = overlayRef . overlayElement . getBoundingClientRect ( ) ;
2170+
2171+ expect ( Math . floor ( overlayRect . width ) ) . toBe ( rightOffset ) ;
2172+ } ) ;
2173+
2174+
2175+
20822176 } ) ;
20832177
20842178 describe ( 'onPositionChange with scrollable view properties' , ( ) => {
0 commit comments