-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
304 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
assets/js/components/TimeSeriesLineChart/TimeSeriesLineChart.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import React from 'react'; | ||
|
||
import { render } from '@testing-library/react'; | ||
import TimeSeriesLineChart from './TimeSeriesLineChart'; | ||
import '@testing-library/jest-dom'; | ||
|
||
describe('TimeSeriesLineChart component', () => { | ||
it('should raise an error if the datasets are more then 5', () => { | ||
const datasets = [ | ||
{ | ||
name: 'Data 1', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
{ | ||
name: 'Data 2', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
{ | ||
name: 'Data 3', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
{ | ||
name: 'Data 4', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
{ | ||
name: 'Data 5', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
{ | ||
name: 'Data 6', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
]; | ||
|
||
expect(() => | ||
render( | ||
<div> | ||
<TimeSeriesLineChart | ||
title="test chart" | ||
start={new Date()} | ||
end={new Date()} | ||
datasets={datasets} | ||
onIntervalChange={() => {}} | ||
/> | ||
</div> | ||
) | ||
).toThrow('TimeSeriesLineChart component supports a maximum of 5 datasets'); | ||
}); | ||
|
||
it('should render with the appropriate props', () => { | ||
const datasets = [ | ||
{ | ||
name: 'Data 1', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
{ | ||
name: 'Data 2', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
{ | ||
name: 'Data 3', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
{ | ||
name: 'Data 4', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
{ | ||
name: 'Data 5', | ||
timeFrames: [{ time: new Date(), value: 0.0 }], | ||
}, | ||
]; | ||
|
||
const { container } = render( | ||
<div> | ||
<TimeSeriesLineChart | ||
title="test chart" | ||
start={new Date()} | ||
end={new Date()} | ||
datasets={datasets} | ||
onIntervalChange={() => {}} | ||
/> | ||
</div> | ||
); | ||
|
||
const canvas = container.querySelector('canvas'); | ||
expect(canvas).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.