@@ -114,6 +114,43 @@ describe('calculateFitScale', () => {
114114} )
115115
116116describe ( 'ResponsiveDesignStage' , ( ) => {
117+ it . each ( [
118+ { width : 280 , height : 400 , supportsZoom : true } ,
119+ { width : 280 , height : 400 , supportsZoom : false } ,
120+ { width : 350 , height : 340 , supportsZoom : true } ,
121+ { width : 350 , height : 340 , supportsZoom : false } ,
122+ ] ) (
123+ 'fits an uncapped $width × $height stage with zoom support: $supportsZoom' ,
124+ ( { width, height, supportsZoom } ) => {
125+ vi . stubGlobal ( 'CSS' , { supports : vi . fn ( ( ) => supportsZoom ) } )
126+ act ( ( ) => {
127+ root . render (
128+ createElement (
129+ ResponsiveDesignStage ,
130+ { width, height, maxScale : Number . POSITIVE_INFINITY } ,
131+ createElement ( 'span' , null , 'Preview' )
132+ )
133+ )
134+ } )
135+
136+ const surface = container . firstElementChild ?. firstElementChild
137+ if ( ! ( surface instanceof HTMLElement ) || ! resizeObserver ) {
138+ throw new Error ( 'responsive stage did not mount' )
139+ }
140+ const observer = resizeObserver
141+
142+ act ( ( ) => observer . deliver ( width * 2 , height * 1.5 ) )
143+ expect ( surface . style . zoom ) . toBe ( supportsZoom ? '1.5' : '1' )
144+ expect ( surface . style . transform ) . toBe ( supportsZoom ? '' : 'scale(1.5)' )
145+ expect ( surface . style . opacity ) . toBe ( '1' )
146+
147+ act ( ( ) => observer . deliver ( width / 2 , height * 2 ) )
148+ expect ( surface . style . zoom ) . toBe ( supportsZoom ? '0.5' : '1' )
149+ expect ( surface . style . transform ) . toBe ( supportsZoom ? '' : 'scale(0.5)' )
150+ expect ( surface . style . opacity ) . toBe ( '1' )
151+ }
152+ )
153+
117154 it ( 'hides an already visible surface until a measurable size returns' , ( ) => {
118155 act ( ( ) => {
119156 root . render (
0 commit comments