Skip to content

Commit

Permalink
fix: correct test
Browse files Browse the repository at this point in the history
  • Loading branch information
louis-jan committed Dec 19, 2024
1 parent b84d4df commit be84f65
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions web/containers/ErrorMessage/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,23 @@ describe('ErrorMessage Component', () => {

beforeEach(() => {
jest.clearAllMocks()
;(useAtomValue as jest.Mock).mockReturnValue([])
;(useSetAtom as jest.Mock).mockReturnValue(mockSetMainState)
;(useSetAtom as jest.Mock).mockReturnValue(mockSetSelectedSettingScreen)
;(useSetAtom as jest.Mock).mockReturnValue(mockSetModalTroubleShooting)
;(useSendChatMessage as jest.Mock).mockReturnValue({
resendChatMessage: mockResendChatMessage,
})
; (useAtomValue as jest.Mock).mockReturnValue([])
; (useSetAtom as jest.Mock).mockReturnValue(mockSetMainState)
; (useSetAtom as jest.Mock).mockReturnValue(mockSetSelectedSettingScreen)
; (useSetAtom as jest.Mock).mockReturnValue(mockSetModalTroubleShooting)
; (useSendChatMessage as jest.Mock).mockReturnValue({
resendChatMessage: mockResendChatMessage,
})
})

it('renders error message with InvalidApiKey correctly', () => {
const message: ThreadMessage = {
id: '1',
status: MessageStatus.Error,
error_code: ErrorCode.InvalidApiKey,
metadata: {
error: MessageStatus.Error,
error_code: ErrorCode.InvalidApiKey,
},
status: "completed",
content: [{ text: { value: 'Invalid API Key' } }],
} as ThreadMessage

Expand All @@ -56,8 +59,11 @@ describe('ErrorMessage Component', () => {
it('renders general error message correctly', () => {
const message: ThreadMessage = {
id: '1',
status: MessageStatus.Error,
error_code: ErrorCode.Unknown,
status: "completed",
metadata: {
error: MessageStatus.Error,
error_code: ErrorCode.Unknown
},
content: [{ text: { value: 'Unknown error occurred' } }],
} as ThreadMessage

Expand All @@ -69,9 +75,11 @@ describe('ErrorMessage Component', () => {
it('opens troubleshooting modal when link is clicked', () => {
const message: ThreadMessage = {
id: '1',
status: MessageStatus.Error,
error_code: ErrorCode.Unknown,
content: [{ text: { value: 'Unknown error occurred' } }],
status: "completed",
metadata: {
error: MessageStatus.Error,
error_code: ErrorCode.Unknown,
}, content: [{ text: { value: 'Unknown error occurred' } }],
} as ThreadMessage

render(<ErrorMessage message={message} />)
Expand Down

0 comments on commit be84f65

Please sign in to comment.