update types/naming to reflect intended usage for useGraphData hook

This commit is contained in:
Loewy
2024-01-12 16:21:40 -08:00
parent 12c3a6ef6f
commit 7faa25e103
4 changed files with 27 additions and 25 deletions

View File

@@ -1,9 +1,9 @@
import { renderHook } from '@testing-library/react-native';
import { useGraphData } from '../../component/charts/use-graph-data';
import { GraphData, Props } from '../../component/charts/graph-types';
import { GraphData, GraphProps } from '../../component/charts/graph-types';
describe('useGraphData', () => {
it('should return correctly processed data from convertToBarData', () => {
it('should return correctly processed data from convertToGraphData', () => {
// mock values
const mockGraphData: GraphData = {
xValues: ['full hit', '3/4 ball ball', '1/2 ball'],
@@ -13,7 +13,7 @@ describe('useGraphData', () => {
]
};
const mockProps: Partial<Props> = {
const mockProps: Partial<GraphProps> = {
yAxisProps: {
maxLeftYAxisValue: 30,
maxRightYAxisValue: 60,
@@ -27,7 +27,7 @@ describe('useGraphData', () => {
const { result } = renderHook(() => useGraphData(mockGraphData, mockProps));
// values expected
const expectedBarData = [
const expectedYData = [
{
data: [{ value: 33.33 }, { value: 66.67 }, { value: 100 }],
svg: { fill: 'transparent' },
@@ -43,9 +43,9 @@ describe('useGraphData', () => {
expect(result.current).toBeDefined();
expect(result.current.xValues).toEqual(['full hit', '3/4 ball ball', '1/2 ball']);
result.current.barData.forEach((barDataItem, index) => {
barDataItem.data.forEach((dataItem, dataIndex) => {
expect(dataItem.value).toBeCloseTo(expectedBarData[index].data[dataIndex].value, 2);
result.current.yData.forEach((yDataItem, index) => {
yDataItem.data.forEach((dataItem, dataIndex) => {
expect(dataItem.value).toBeCloseTo(expectedYData[index].data[dataIndex].value, 2);
});
});
expect(result.current.yAxisLeftLabels).toEqual(expectedLeftLabels);