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