Skip to content

Commit

Permalink
🔧 Small refactoring in how it's defined test component
Browse files Browse the repository at this point in the history
  • Loading branch information
Serloni committed Jun 19, 2024
1 parent 9cbb8f2 commit 53f21ef
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {render, screen} from '@testing-library/react';
import Theme from 'util/Theme';
import {ThemeProvider} from '@mui/system';

export default function CardContainerTest() {
const CardContainerTest = () => {
// Mock data for the props
const compartmentsExpanded = true;
const selectedCompartment = 'Compartment 1';
Expand Down Expand Up @@ -94,7 +94,7 @@ export default function CardContainerTest() {
</ThemeProvider>
</div>
);
}
};

describe('CardContainer', () => {
test('renders data cards correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import Theme from 'util/Theme';
import {ThemeProvider} from '@mui/system';
import DataCard from 'components/ScenarioComponents/CardsComponents/DataCard';

function DataCardTest() {
const DataCardTest = () => {
const Index = 0;
const CompartmentValues: Dictionary<number> = {
'Compartment 1': 10,
Expand Down Expand Up @@ -105,7 +105,7 @@ function DataCardTest() {
/>
</ThemeProvider>
);
}
};

describe('DataCard', () => {
test('renders DataCard correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ interface CardTooltipTestInterface {
activeScenario: boolean;
scenarios: number[];
}

export default function CardTooltipTest({hovertest, scenarios, index, activeScenario}: CardTooltipTestInterface) {
const CardTooltipTest = ({hovertest, scenarios, index, activeScenario}: CardTooltipTestInterface) => {
const color = '#00000';
const [activeScenarios, setActiveScenarios] = useState<number[] | null>(scenarios);
const [numberSelectedScenario, setSelectedScenario] = useState<number | null>(index);
Expand All @@ -36,7 +35,7 @@ export default function CardTooltipTest({hovertest, scenarios, index, activeScen
/>
</ThemeProvider>
);
}
};

describe('CardTooltip', () => {
test('renders the tooltip when hover is true', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Theme from 'util/Theme';
import {Dictionary} from 'types/Cardtypes';
import MainCard from 'components/ScenarioComponents/CardsComponents/MainCard/MainCard';

function MainCardTest() {
const MainCardTest = () => {
const Index = 0;
const CompartmentValues: Dictionary<number> = {
'Compartment 1': 10,
Expand Down Expand Up @@ -61,7 +61,7 @@ function MainCardTest() {
/>
</ThemeProvider>
);
}
};

describe('MainCard', () => {
test('renders MainCard correctly', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Theme from 'util/Theme';
import CompartmentsRow from 'components/ScenarioComponents/CompartmentsComponents/CompartmentsRow';
import userEvent from '@testing-library/user-event';

export default function CompartmentsRowTest() {
const CompartmentsRowTest = () => {
const compartmentsExpanded = true;
const compartments = ['Compartment 1', 'Compartment 2', 'Compartment 3'];
const [selectedCompartment, setSelectedCompartment] = useState('Compartment 1');
Expand Down Expand Up @@ -38,7 +38,7 @@ export default function CompartmentsRowTest() {
</ThemeProvider>
</div>
);
}
};

describe('CompartmentsRows', () => {
test('renders the correct compartment names', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {ThemeProvider} from '@emotion/react';
import {render, screen, waitFor} from '@testing-library/react';
import Theme from 'util/Theme';

export default function CompartmentsRowsTest() {
const CompartmentsRowsTest = () => {
const compartmentsExpanded = true;
const compartments = ['Compartment 1', 'Compartment 2', 'Compartment 3'];
const [selectedCompartment, setSelectedCompartment] = useState('Compartment 1');
Expand All @@ -35,7 +35,7 @@ export default function CompartmentsRowsTest() {
</ThemeProvider>
</div>
);
}
};

describe('CompartmentsRows', () => {
test('renders the correct number of compartments', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {ThemeProvider} from '@emotion/react';

import Theme from 'util/Theme';

export default function GeneralButtonTest() {
const GeneralButtonTest = () => {
const buttonTexts = {clicked: 'Clicked', unclicked: 'Unclicked'};
const isDisabled = () => true;
const handleClick = () => {};
Expand All @@ -21,7 +21,7 @@ export default function GeneralButtonTest() {
</ThemeProvider>
</div>
);
}
};

describe('GeneralButtonTest', () => {
test('renders the button with the correct initial text', async () => {
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/LineChartComponents/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ export default function LineChart({
const globalPosition = xAxis.toGlobal({x: xAxisPosition, y: 0});
const docPosition = root.rootPointToDocument(globalPosition).x;
setReferenceDayBottom(docPosition);
}, [chart, root, xAxis, referenceDay]);
}, [chart, root, xAxis, referenceDay, setReferenceDayBottom]);

useLayoutEffect(() => {
if (!root || !chart || !xAxis) {
Expand Down Expand Up @@ -449,7 +449,7 @@ export default function LineChart({
? color(getScenarioPrimaryColor(selectedScenario, theme))
: undefined,
};
}, [selectedScenario, theme.custom.scenarios, xAxis, yAxis, chartId, theme]);
}, [selectedScenario, xAxis, yAxis, chartId, theme]);
useLineSeries(
root,
chart,
Expand Down Expand Up @@ -486,7 +486,7 @@ export default function LineChart({
}),
stroke: color(getScenarioPrimaryColor(scenario.id, theme)),
}));
}, [scenarioList, root, simulationDataChartName, theme.custom.scenarios, xAxis, yAxis, chartId, theme]);
}, [scenarioList, root, simulationDataChartName, xAxis, yAxis, chartId, theme]);
useLineSeriesList(
root,
chart,
Expand Down Expand Up @@ -532,7 +532,7 @@ export default function LineChart({
}),
stroke: color(getScenarioPrimaryColor(selectedScenario, theme)),
}));
}, [groupFilterList, root, selectedScenario, theme.custom.scenarios, xAxis, yAxis, chartId, theme]);
}, [groupFilterList, root, selectedScenario, xAxis, yAxis, chartId, theme]);
useLineSeriesList(
root,
chart,
Expand Down

0 comments on commit 53f21ef

Please sign in to comment.