update tests, change naming
This commit is contained in:
parent
6c7ceb3eb3
commit
dee04269bd
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { Path } from 'react-native-svg';
|
||||
|
||||
import { calculateBarProps, drawBarPath } from './custom-bar-utils';
|
||||
import { calculateBarOrigin, drawBarPath } from './custom-bar-utils';
|
||||
import { ScaleFunction } from './graph-types';
|
||||
|
||||
interface BarProps {
|
||||
@ -27,7 +27,7 @@ export const Bar: React.FC<BarProps> = ({
|
||||
gap,
|
||||
roundedRadius
|
||||
}) => {
|
||||
const { xOrigin, yOrigin, height } = calculateBarProps({
|
||||
const { xOrigin, yOrigin, height } = calculateBarOrigin({
|
||||
scaleX,
|
||||
scaleY,
|
||||
index,
|
||||
|
@ -12,7 +12,7 @@ type BarCalculationProps = {
|
||||
gap: number;
|
||||
};
|
||||
|
||||
export function calculateBarProps({
|
||||
export function calculateBarOrigin({
|
||||
scaleX,
|
||||
scaleY,
|
||||
barWidth,
|
||||
|
@ -41,8 +41,8 @@ export const CustomBars: React.FC<CustomBarsProps> = ({
|
||||
scaleX={scaleX}
|
||||
scaleY={scaleY}
|
||||
data={item.data[index]}
|
||||
barNumber={i}
|
||||
index={index}
|
||||
barNumber={i} // index of bar
|
||||
index={index} // index of group
|
||||
fill={barColors[i]}
|
||||
barWidth={barWidth}
|
||||
gap={gap}
|
||||
|
@ -4,7 +4,7 @@ import "@testing-library/jest-native/extend-expect";
|
||||
import * as scale from 'd3-scale'
|
||||
|
||||
import { CustomBars } from '../../component/custom-bars';
|
||||
import { calculateBarProps, drawBarPath } from '../../component/custom-bar-utils';
|
||||
import { calculateBarOrigin, drawBarPath } from '../../component/custom-bar-utils';
|
||||
|
||||
|
||||
const mockYScaleFunction = scale.scaleLinear();
|
||||
@ -47,7 +47,7 @@ describe('CustomBars Component Tests', () => {
|
||||
});
|
||||
|
||||
describe('Bar utility functions', () => {
|
||||
describe('calculateBarProps', () => {
|
||||
describe('calculateBarOrigin', () => {
|
||||
it('calculates properties correctly', () => {
|
||||
const mockData = { value: 10 };
|
||||
const mockIndex = 1;
|
||||
@ -55,7 +55,7 @@ describe('Bar utility functions', () => {
|
||||
const mockBarWidth = 20;
|
||||
const mockGap = 5;
|
||||
|
||||
const result = calculateBarProps({
|
||||
const result = calculateBarOrigin({
|
||||
scaleX: mockXScaleFunction,
|
||||
scaleY: mockYScaleFunction,
|
||||
data: mockData,
|
||||
@ -81,10 +81,9 @@ describe('Bar utility functions', () => {
|
||||
const roundedRadius = 10;
|
||||
|
||||
const path = drawBarPath(xOrigin, yOrigin, barWidth, height, roundedRadius);
|
||||
const expectedPath = 'M50,160L50,110A10,10,0,0,1,60,100L60,100A10,10,0,0,1,70,110L70,160L50,160Z'
|
||||
|
||||
expect(typeof path).toBe('string');
|
||||
const regexPattern = /M.*,.*L.*,.*A.*,.*,.*,.*,.*,.*,.*L.*,.*A.*,.*,.*,.*,.*,.*,.*L.*,.*L.*,.*Z/;
|
||||
expect(path).toMatch(regexPattern);
|
||||
expect(path).toBe(expectedPath);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user