Some improvements on LineChartCard

This commit is contained in:
Alejandro Celaya
2020-05-30 17:39:08 +02:00
parent 9340512980
commit 1b6028ae6d
3 changed files with 88 additions and 12 deletions

View File

@@ -3,8 +3,9 @@ import { shallow } from 'enzyme';
import { CardHeader, DropdownItem } from 'reactstrap';
import { Line } from 'react-chartjs-2';
import LineChartCard from '../../../src/visits/helpers/LineChartCard';
import Checkbox from '../../../src/utils/Checkbox';
describe('<LineCHartCard />', () => {
describe('<LineChartCard />', () => {
let wrapper;
const createWrapper = (visits = [], highlightedVisits = []) => {
wrapper = shallow(<LineChartCard title="Cool title" visits={visits} highlightedVisits={highlightedVisits} />);
@@ -49,6 +50,15 @@ describe('<LineCHartCard />', () => {
ticks: { beginAtZero: true, precision: 0 },
},
],
xAxes: [
{
scaleLabel: { display: true, labelString: 'Month' },
},
],
},
tooltips: {
intersect: false,
axis: 'x',
},
});
});
@@ -63,4 +73,15 @@ describe('<LineCHartCard />', () => {
expect(datasets).toHaveLength(expectedLines);
});
it('includes stats for visits with no dates if selected', () => {
const wrapper = createWrapper([
{ date: '2016-04-01' },
{ date: '2016-01-01' },
]);
expect(wrapper.find(Line).prop('data').labels).toHaveLength(2);
wrapper.find(Checkbox).simulate('change');
expect(wrapper.find(Line).prop('data').labels).toHaveLength(4);
});
});