2018-11-20 22:21:47 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
2019-03-06 20:12:28 +00:00
|
|
|
import { getChartMode, getSelectedFilter } from '../utils';
|
2018-11-20 22:21:47 +00:00
|
|
|
|
|
|
|
describe( 'ReportChart', () => {
|
|
|
|
test( 'should set the mode prop depending on the active filter', () => {
|
|
|
|
const filters = [
|
|
|
|
{
|
|
|
|
param: 'filter',
|
|
|
|
showFilters: () => true,
|
|
|
|
filters: [
|
|
|
|
{
|
|
|
|
value: 'lorem-ipsum',
|
|
|
|
chartMode: 'item-comparison',
|
|
|
|
settings: {
|
|
|
|
param: 'filter2',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
const query = { filter: 'lorem-ipsum', filter2: 'ipsum-lorem' };
|
2019-03-06 20:12:28 +00:00
|
|
|
const selectedFilter = getSelectedFilter( filters, query );
|
|
|
|
const mode = getChartMode( selectedFilter, query );
|
2019-02-05 18:12:58 +00:00
|
|
|
expect( mode ).toEqual( 'item-comparison' );
|
2018-11-20 22:21:47 +00:00
|
|
|
} );
|
|
|
|
} );
|