diff --git a/src/components/ChatBox/index.test.jsx b/src/components/ChatBox/index.test.jsx index 915199a6..889ac6de 100644 --- a/src/components/ChatBox/index.test.jsx +++ b/src/components/ChatBox/index.test.jsx @@ -82,20 +82,21 @@ describe('', () => { expect(screen.queryByText('Today')).toBeInTheDocument(); }); - // todo: correctly divides old and new messages, check order it('correctly divides old and new messages', () => { const today = new Date(); const messageList = [ - { role: 'user', content: 'hi yesterday', timestamp: today.setDate(today.getDate() - 1) }, - { role: 'user', content: 'hi today', timestamp: +Date.now() }, + { role: 'user', content: 'Today yesterday', timestamp: today.setDate(today.getDate() - 1) }, + { role: 'user', content: 'Today today', timestamp: +Date.now() }, ]; const sliceState = { messageList, }; render(undefined, sliceState); - expect(screen.queryByText('hi yesterday')).toBeInTheDocument(); - expect(screen.queryByText('hi today')).toBeInTheDocument(); - expect(screen.queryByText('Today')).toBeInTheDocument(); + const results = screen.getAllByText('Today', { exact: false }); + expect(results.length).toBe(3); + expect(results[0]).toHaveTextContent('Today yesterday'); + expect(results[1]).toHaveTextContent('Today'); + expect(results[2]).toHaveTextContent('Today today'); }); });