Skip to content

Commit 24532f6

Browse files
committed
FE: Added test code for changing default value notation of ConsumerGroups component
1 parent f03f496 commit 24532f6

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { screen } from '@testing-library/react';
2+
import { render } from 'lib/testHelpers';
3+
import { useConsumerGroups } from 'lib/hooks/api/consumers';
4+
import List from '../List';
5+
6+
// Mock hooks
7+
jest.mock('lib/hooks/api/consumers', () => ({
8+
useConsumerGroups: jest.fn(),
9+
}));
10+
11+
jest.mock('react-router-dom', () => ({
12+
...jest.requireActual('react-router-dom'),
13+
useSearchParams: () => [new URLSearchParams(), jest.fn()],
14+
useNavigate: () => jest.fn(),
15+
}));
16+
17+
const mockUseConsumerGroups = useConsumerGroups as jest.Mock;
18+
19+
describe('ConsumerGroups List', () => {
20+
beforeEach(() => {
21+
mockUseConsumerGroups.mockImplementation(() => ({
22+
data: {
23+
consumerGroups: [
24+
{
25+
groupId: 'group1',
26+
consumerLag: 0,
27+
members: 1,
28+
topics: 1,
29+
coordinator: { id: 1 },
30+
state: 'STABLE',
31+
},
32+
{
33+
groupId: 'group2',
34+
consumerLag: null,
35+
members: 1,
36+
topics: 1,
37+
coordinator: { id: 2 },
38+
state: 'STABLE',
39+
},
40+
],
41+
pageCount: 1,
42+
},
43+
isSuccess: true,
44+
isFetching: false,
45+
}));
46+
});
47+
48+
it('renders consumer lag values correctly', () => {
49+
render(<List />);
50+
const tableRows = screen.getAllByRole('row');
51+
expect(tableRows[1]).toHaveTextContent('0');
52+
expect(tableRows[2]).toHaveTextContent('N/A');
53+
});
54+
});

0 commit comments

Comments
 (0)