-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Harmanpreet Kaur
committed
Sep 24, 2024
1 parent
906dc6b
commit 31cbc41
Showing
5 changed files
with
149 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import { render, RenderResult } from '@testing-library/react'; | ||
import { AppStateContext } from '../state/AppProvider'; | ||
import { Conversation, ChatMessage } from '../api/models'; | ||
|
||
// Default mock state | ||
const defaultMockState = { | ||
currentChat: null, | ||
articlesChat: null, | ||
grantsChat: null, | ||
frontendSettings: null, | ||
documentSections: null, | ||
researchTopic: "Test topic", | ||
favoritedCitations: [], | ||
isSidebarExpanded: false, | ||
isChatViewOpen: true, | ||
sidebarSelection: null, | ||
showInitialChatMessage: false, | ||
}; | ||
|
||
const mockDispatch = jest.fn(); | ||
|
||
// Create a custom render function | ||
const renderWithContext = ( | ||
component: React.ReactElement, | ||
contextState = {} | ||
): RenderResult => { | ||
const state = { ...defaultMockState, ...contextState }; | ||
return render( | ||
<AppStateContext.Provider value={{ state, dispatch: mockDispatch }}> | ||
{component} | ||
</AppStateContext.Provider> | ||
); | ||
}; | ||
|
||
// Mocked conversation and chat message | ||
const mockChatMessage: ChatMessage = { | ||
id: 'msg1', | ||
role: 'user', | ||
content: 'Test message content', | ||
date: new Date().toISOString(), | ||
}; | ||
|
||
const mockConversation: Conversation = { | ||
id: '1', | ||
title: 'Test Conversation', | ||
messages: [mockChatMessage], | ||
date: new Date().toISOString(), | ||
}; | ||
|
||
export { defaultMockState, renderWithContext, mockDispatch, mockChatMessage, mockConversation }; | ||
export * from '@testing-library/react'; |