@@ -169,5 +169,51 @@ describe('render Resizable', () => {
169169 } )
170170 ) ;
171171 } ) ;
172+
173+ test ( 'use of < 1 transformScale' , ( ) => {
174+ const element = shallow ( < Resizable { ...customProps } transformScale = { 0.5 } > { resizableBoxChildren } </ Resizable > ) ;
175+ const nwHandle = element . find ( 'DraggableCore' ) . first ( ) ;
176+ expect ( props . onResize ) . not . toHaveBeenCalled ( ) ;
177+ nwHandle . prop ( 'onDrag' ) ( mockEvent , { node, deltaX : 5 , deltaY : 10 } ) ;
178+ expect ( props . onResize ) . lastCalledWith (
179+ mockEvent ,
180+ expect . objectContaining ( {
181+ size : {
182+ // Should be doubled
183+ height : 30 ,
184+ width : 40 ,
185+ } ,
186+ } )
187+ ) ;
188+
189+ mockClientRect . left = 20 ; // Object moves between callbacks
190+ nwHandle . prop ( 'onDrag' ) ( mockEvent , { node, deltaX : 5 , deltaY : 10 } ) ;
191+ expect ( props . onResize ) . lastCalledWith (
192+ mockEvent ,
193+ expect . objectContaining ( {
194+ size : {
195+ height : 30 , // Height decreased as deltaY increases - no further top position change since last
196+ width : 20 , // Width decreased 10 from deltaX and 20 from changing position
197+ } ,
198+ } )
199+ ) ;
200+ } ) ;
201+
202+ test ( 'use of > 1 transformScale' , ( ) => {
203+ const element = shallow ( < Resizable { ...customProps } transformScale = { 2 } > { resizableBoxChildren } </ Resizable > ) ;
204+ const nwHandle = element . find ( 'DraggableCore' ) . first ( ) ;
205+ expect ( props . onResize ) . not . toHaveBeenCalled ( ) ;
206+ nwHandle . prop ( 'onDrag' ) ( mockEvent , { node, deltaX : 5 , deltaY : 10 } ) ;
207+ expect ( props . onResize ) . lastCalledWith (
208+ mockEvent ,
209+ expect . objectContaining ( {
210+ size : {
211+ // Should be halved
212+ height : 45 ,
213+ width : 47.5 ,
214+ } ,
215+ } )
216+ ) ;
217+ } ) ;
172218 } ) ;
173219} ) ;
0 commit comments