update tests, change naming

This commit is contained in:
Loewy
2024-01-10 18:09:47 -08:00
parent 6c7ceb3eb3
commit dee04269bd
4 changed files with 10 additions and 11 deletions

View File

@@ -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);
});
});
});