Skip to content

Commit

Permalink
fix the spec files
Browse files Browse the repository at this point in the history
  • Loading branch information
Mgrdich committed Mar 14, 2024
1 parent 12cd051 commit 237a6e4
Showing 1 changed file with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import MessagesTable, {
MessagesTableProps,
} from 'components/Topics/Topic/Messages/MessagesTable';
import { TopicMessage, TopicMessageTimestampTypeEnum } from 'generated-sources';
import { useIsLiveMode } from 'lib/hooks/useMessagesFilters';

import { useMessageFiltersStore } from '../../../../../lib/hooks/useMessageFiltersStore';

export const topicMessagePayload: TopicMessage = {
partition: 29,
Expand All @@ -27,15 +30,15 @@ jest.mock('react-router-dom', () => ({
useNavigate: () => mockNavigate,
}));

jest.mock('lib/hooks/useMessagesFilters', () => ({
useIsLiveMode: jest.fn(),
useRefreshData: jest.fn(),
}));

describe('MessagesTable', () => {
const renderComponent = (props?: Partial<MessagesTableProps>) => {
return render(
<MessagesTable
messages={[]}
isFetching={false}
nextCursor={null}
{...props}
/>
<MessagesTable messages={[]} isFetching={false} {...props} />
);
};

Expand Down Expand Up @@ -67,14 +70,15 @@ describe('MessagesTable', () => {
});

describe('Custom Setup with different props value', () => {
it('should check if next button and previous is disabled isLive Param', () => {
it('should check if next button is disabled isLive Param', () => {
renderComponent({ isFetching: true });
expect(screen.queryByText(/next/i)).toBeDisabled();
});

it('should check if next button there is not nextCursor', () => {
renderComponent({ nextCursor: 'nextCursor', isFetching: false });
expect(screen.queryByText(/next/i)).toBeEnabled();
it('should check if next button is disabled if there is no nextCursor', () => {
(useIsLiveMode as jest.Mock).mockImplementation(() => false);
renderComponent({ isFetching: false });
expect(screen.queryByText(/next/i)).toBeDisabled();
});

it('should check the display of the loader element during loader', () => {
Expand Down

0 comments on commit 237a6e4

Please sign in to comment.