From 237a6e4e8bf68e9f4dc2700ec3e0313ad6ace25a Mon Sep 17 00:00:00 2001 From: Mgrdich Date: Thu, 14 Mar 2024 23:07:54 +0400 Subject: [PATCH] fix the spec files --- .../Messages/__test__/MessagesTable.spec.tsx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/Topics/Topic/Messages/__test__/MessagesTable.spec.tsx b/frontend/src/components/Topics/Topic/Messages/__test__/MessagesTable.spec.tsx index 01d88fc98..33e681b21 100644 --- a/frontend/src/components/Topics/Topic/Messages/__test__/MessagesTable.spec.tsx +++ b/frontend/src/components/Topics/Topic/Messages/__test__/MessagesTable.spec.tsx @@ -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, @@ -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) => { return render( - + ); }; @@ -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', () => {