Skip to content

Commit

Permalink
Fixed unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Cai <yicai@redhat.com>
  • Loading branch information
ciiay committed Oct 15, 2024
1 parent 3d0310b commit 65c4256
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('TopologyComponent', () => {
it('should render TopologyComponent', () => {
useThemeMock.mockReturnValue({
palette: {
type: 'dark',
mode: 'dark',
},
});
const { getByText } = render(<TopologyComponent />);
Expand All @@ -67,7 +67,7 @@ describe('TopologyComponent', () => {
it('should show dark theme', () => {
useThemeMock.mockReturnValue({
palette: {
type: 'dark',
mode: 'dark',
},
});
render(<TopologyComponent />);
Expand All @@ -78,7 +78,7 @@ describe('TopologyComponent', () => {
it('should show light theme', () => {
useThemeMock.mockReturnValue({
palette: {
type: 'light',
mode: 'light',
},
});
render(<TopologyComponent />);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import { render } from '@testing-library/react';
import { mockTektonResources } from '../../../__fixtures__/1-tektonResources';
import PLRlist from './PLRlist';

jest.mock('@mui/material/styles', () => ({
...jest.requireActual('@mui/material/styles'),
jest.mock('@material-ui/styles', () => ({
...jest.requireActual('@material-ui/styles'),
makeStyles: () => (_theme: any) => {
return {
ok: 'ok',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('ContainerSelector', () => {
/>,
);

fireEvent.mouseDown(getByRole('button'));
fireEvent.mouseDown(getByRole('combobox'));
const listbox = within(getByRole('listbox'));

fireEvent.click(listbox.getByText(/container2/i));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,14 @@ import React from 'react';

import { V1Container } from '@kubernetes/client-node';
import MenuItem from '@mui/material/MenuItem';
import Select from '@mui/material/Select';
import { SelectChangeEvent } from '@mui/material/Select';
import Select, { SelectChangeEvent } from '@mui/material/Select';

import ResourceName from '../../../../common/components/ResourceName';

type ContainerSelectorType = {
containersList: V1Container[];
containerSelected: string;
onContainerChange: (
event: SelectChangeEvent<{
name?: string;
value: unknown;
}>,
child: React.ReactNode,
) => void;
onContainerChange: (event: SelectChangeEvent, child: React.ReactNode) => void;
};

export const ContainerSelector = ({
Expand All @@ -44,7 +37,7 @@ export const ContainerSelector = ({
onChange={onContainerChange}
label="Container"
style={{ marginLeft: '20px' }}
value={{ value: containerSelected }}
value={containerSelected}
data-testid="container-select"
>
{containersList.map(container => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ const ViewLogs = ({ podData, onClose }: ViewLogsProps) => {
clusterName: curCluster,
});

const onContainerChange = (
event: SelectChangeEvent<{ name?: string; value: unknown }>,
) => {
setContainerSelected(event.target.value as string);
const onContainerChange = (event: SelectChangeEvent) => {
setContainerSelected(event.target.value);
};

React.useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {
} from '../../../__fixtures__/workloadNodeData';
import TopologyResourcesTabPanel from './TopologyResourcesTabPanel';

jest.mock('@mui/material/styles', () => ({
...jest.requireActual('@mui/material/styles'),
jest.mock('@material-ui/styles', () => ({
...jest.requireActual('@material-ui/styles'),
makeStyles: () => (_theme: any) => {
return {
ok: 'ok',
Expand Down

0 comments on commit 65c4256

Please sign in to comment.