Skip to content

Commit

Permalink
test: remove tests that do not update the channel read state
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinCupela committed Jan 27, 2025
1 parent c1b6e9d commit e654e89
Showing 1 changed file with 0 additions and 88 deletions.
88 changes: 0 additions & 88 deletions src/components/MessageList/__tests__/MessageList.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,94 +370,6 @@ describe('MessageList', () => {
afterEach(jest.clearAllMocks);
afterAll(jest.restoreAllMocks);

it('should keep displaying the unread messages separator when an unread channel is marked read on mount', async () => {
const user = generateUser();
const last_read_message_id = 'X';
const lastReadMessage = generateMessage({ id: last_read_message_id });
const messages = [lastReadMessage, generateMessage(), generateMessage()];
const {
channels: [channel],
client: chatClient,
} = await initClientWithChannels({
channelsData: [
{
messages,
read: [
{
last_read: lastReadMessage.created_at.toISOString(),
last_read_message_id,
unread_messages: 2,
user,
},
],
},
],
customUser: user,
});

const markReadMock = jest
.spyOn(channel, 'markRead')
.mockReturnValueOnce(markReadApi(channel));

await act(() => {
renderComponent({
channelProps: { channel },
chatClient,
msgListProps: { messages },
});
});

expect(markReadMock).toHaveBeenCalledTimes(1);
expect(screen.queryByText(separatorText)).toBeInTheDocument();
});

it('should display unread messages separator before the first message', async () => {
const user = generateUser();
const messages = [generateMessage(), generateMessage()];
const {
channels: [channel],
client: chatClient,
} = await initClientWithChannels({
channelsData: [
{
messages,
read: [
{
last_read: new Date(1).toISOString(),
unread_messages: messages.length,
user,
},
],
},
],
customUser: user,
});

const markReadMock = jest.spyOn(channel, 'markRead').mockReturnValue(markReadApi(channel));
const Message = () => <div className='message-ui' />;
let container;

await act(() => {
const result = renderComponent({
channelProps: { channel, Message },
chatClient,
msgListProps: { messages },
});
container = result.container;
});
const listItems = container.querySelectorAll('.str-chat__ul > *');
expect(listItems).toHaveLength(4);
expect(listItems[1].firstChild).toMatchInlineSnapshot(`
<div
class="str-chat__unread-messages-separator"
data-testid="unread-messages-separator"
>
Unread messages
</div>
`);
markReadMock.mockRestore();
});

it('should display unread messages separator when a channel is marked unread and remove it when marked read by markRead()', async () => {
jest.useFakeTimers();
const markReadBtnTestId = 'test-mark-read';
Expand Down

0 comments on commit e654e89

Please sign in to comment.