import React from 'react' ; import { shallow } from 'enzyme' ; import { Cell } from './cell' ; import { HeaderRow } from './header_row' ; interface Foo { id : number ; } describe ( 'HeaderRow' , ( ) => { const columns = [ { name : 'ID' , render : ( item ) => < div > { item . id } < /div> }, { name : 'Whatever' , render : ( ) => 'Whatever' } , ] ; it ( 'renders a table header row from the provided column names' , ( ) => { const wrapper = shallow ( < HeaderRow columns = { columns } / > ) ; const cells = wrapper . find ( Cell ) ; expect ( cells . length ) . toBe ( 2 ) ; expect ( cells . at ( 0 ) . children ( ) . dive ( ) . text ( ) ) . toEqual ( 'ID' ) ; expect ( cells . at ( 1 ) . children ( ) . dive ( ) . text ( ) ) . toEqual ( 'Whatever' ) ; } ) ; it ( 'will render an additional cell in the first column if one is provided' , ( ) => { const wrapper = shallow ( < HeaderRow columns = { columns } leftAction = { < div > Left Action < /div>}/ > ) ; const cells = wrapper . find ( Cell ) ; expect ( cells . length ) . toBe ( 3 ) ; } ) ; } ) ;