import React from 'react' ; import renderer from 'react-test-renderer' ; import ZoomHandler , { transformToString } from './ZoomHandler.component' ; describe ( 'ZoomHandler renders correctly' , ( ) => { describe ( '<ZoomHandler /> renders correctly' , ( ) => { it ( '<ZoomHandler /> renders correctly' , ( ) => { const transform = { x : 0 , y : 0 , k : 1 } ; const tree = renderer . create ( < ZoomHandler transform = { transform } > < rect /> < rect / > < /ZoomHandler>) . toJSON ( ) ; expect ( tree ) . toMatchSnapshot ( ) ; } ) ; } ) ; describe ( 'transformToString' , ( ) => { it ( 'generate proper transform string' , ( ) => { const transform = { x : 1 , y : 2 , k : - 3 } ; const stringResult = transformToString ( transform ) ; expect ( stringResult ) . toEqual ( `translate(${ transform . x }, ${ transform . y }) scale(${ transform . k })` ) ; } ) ; } ) ; } ) ;