import type { Dimension , Dimensions } from '../../../../../xy/public' ; import { getAspects } from './_get_aspects' ; import { Aspect } from './point_series' ; import { Table , Row } from '../../types' ; describe ( 'getAspects' , function ( ) { let table ; let dimensions ; function validate ( aspect , i ) { expect ( aspect ) . toEqual ( expect . any ( Object ) ) ; expect ( aspect ) . toHaveProperty ( 'accessor' , i ) ; } function init ( group , x , y ) { table = { columns : [ { id : '0' , name : 'date' } , { id : '1' , name : 'date utc_time' } , { id : '2' , name : 'ext' } , { id : '3' , name : 'geo.src' } , { id : '4' , name : 'count' } , { id : '5' , name : 'avg bytes' } , ] , rows : [ ] as Row [ ] , } as Table ; dimensions = { x : { accessor : x } as Dimension , y : [ { accessor : y } as Dimension ] , series : [ { accessor : group } as Dimension ] , } as Dimensions ; } it ( 'produces an aspect object for each of the aspect types found in the columns' , function ( ) { init ( 1 , 0 , 2 ) ; const aspects = getAspects ( table , dimensions ) ; validate ( aspects . x [ 0 ] , '0' ) ; validate ( aspects . series ! [ 0 ] , '1' ) ; validate ( aspects . y ! [ 0 ] , '2' ) ; } ) ; it ( 'creates a fake x aspect if the column does not exist' , function ( ) { init ( 0 , null , 1 ) ; const aspects = getAspects ( table , dimensions ) ; expect ( aspects . x [ 0 ] ) . toEqual ( expect . any ( Object ) ) ; expect ( aspects . x [ 0 ] ) . toHaveProperty ( 'accessor' , - 1 ) ; expect ( aspects . x [ 0 ] ) . toHaveProperty ( 'title' ) ; } ) ; } ) ;