import { getDistinctSeries } from './get_distinct_series' ; import { createMockVisData , createMockBucketColumns } from '../mocks' ; const visData = createMockVisData ( ) ; const buckets = createMockBucketColumns ( ) ; describe ( 'getDistinctSeries' , ( ) => { it ( 'should return the distinct values for all buckets' , ( ) => { const { allSeries } = getDistinctSeries ( visData . rows , buckets ) ; expect ( allSeries ) . toEqual ( [ 'Logstash Airways' , 'JetBeats' , 'ES-Air' , 'Kibana Airlines' , 0 , 1 ] ) ; } ) ; it ( 'should return only the distinct values for the parent bucket' , ( ) => { const { parentSeries } = getDistinctSeries ( visData . rows , buckets ) ; expect ( parentSeries ) . toEqual ( [ 'Logstash Airways' , 'JetBeats' , 'ES-Air' , 'Kibana Airlines' ] ) ; } ) ; it ( 'should return empty array for empty buckets' , ( ) => { const { parentSeries } = getDistinctSeries ( visData . rows , [ { name : 'Count' } ] ) ; expect ( parentSeries . length ) . toEqual ( 0 ) ; } ) ; } ) ;