Skip to content

Commit

Permalink
add testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
bxdoan committed Jan 14, 2025
1 parent 48427e5 commit 7d4f9e7
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions web/hooks/useDeleteThread.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,20 +130,14 @@ describe('useDeleteThread', () => {
const mockSetThreads = jest.fn()
;(useAtom as jest.Mock).mockReturnValue([mockThreads, mockSetThreads])

// Tạo các mock functions riêng biệt
// create mock functions
const mockSetCurrentPrompt = jest.fn()
const mockSetActiveThreadId = jest.fn()
const mockDeleteMessages = jest.fn()
const mockDeleteThreadState = jest.fn()

// Mock useSetAtom cho từng atom riêng biệt
// mock useSetAtom for each atom
let currentAtom: any
;(useSetAtom as jest.Mock).mockImplementation((atom) => {
currentAtom = atom
if (currentAtom === currentPromptAtom) return mockSetCurrentPrompt
if (currentAtom === setActiveThreadIdAtom) return mockSetActiveThreadId
if (currentAtom === deleteChatMessagesAtom) return mockDeleteMessages
if (currentAtom === deleteThreadStateAtom) return mockDeleteThreadState
return jest.fn()
})

Expand Down

0 comments on commit 7d4f9e7

Please sign in to comment.