import { ConnectionElement } from '../../../common/service_map' ; import { groupResourceNodes } from './group_resource_nodes' ; import expectedGroupedData from './mock_responses/group_resource_nodes_grouped.json' ; import preGroupedData from './mock_responses/group_resource_nodes_pregrouped.json' ; describe ( 'groupResourceNodes' , ( ) => { it ( 'should group external nodes' , ( ) => { const responseWithGroups = groupResourceNodes ( preGroupedData as { elements : ConnectionElement [ ] ; } ) ; expect ( responseWithGroups . elements ) . toHaveLength ( expectedGroupedData . elements . length ) ; for ( const element of responseWithGroups . elements ) { const expectedElement = expectedGroupedData . elements . find ( ( { data : { id } } ) => id === element . data . id ) ! ; expect ( element ) . toMatchObject ( expectedElement ) ; } } ) ; } ) ;