Add chat hiding mentions follow counts waveform and post fixes
This commit is contained in:
@@ -27,6 +27,7 @@ describe('ChatService realtime message broadcasting', () => {
|
||||
markMessageSeen: jest.fn().mockResolvedValue(undefined),
|
||||
clearConversationUnreadForUser: jest.fn().mockResolvedValue(undefined),
|
||||
markMessageDelivered: jest.fn().mockResolvedValue(undefined),
|
||||
hideConversationForUser: jest.fn().mockResolvedValue(conversation),
|
||||
};
|
||||
notificationsService = {
|
||||
createMessageNotification: jest.fn().mockResolvedValue(null),
|
||||
@@ -163,4 +164,30 @@ describe('ChatService realtime message broadcasting', () => {
|
||||
});
|
||||
expect(result.seenAt).toEqual(expect.any(String));
|
||||
});
|
||||
|
||||
it('hides a conversation for the current user only', async () => {
|
||||
const result = await service.hideConversationForMe(senderId, conversationId);
|
||||
|
||||
expect(chatRepository.findConversationById).toHaveBeenCalledWith(conversationId);
|
||||
expect(chatRepository.hideConversationForUser).toHaveBeenCalledWith(
|
||||
conversationId,
|
||||
senderId,
|
||||
expect.any(Date),
|
||||
);
|
||||
expect(chatRepository.createMessage).not.toHaveBeenCalled();
|
||||
expect(result).toEqual({
|
||||
success: true,
|
||||
conversationId,
|
||||
deletedForMe: true,
|
||||
});
|
||||
});
|
||||
|
||||
it('does not hide a conversation for a non-participant', async () => {
|
||||
const outsiderId = new Types.ObjectId().toString();
|
||||
|
||||
await expect(service.hideConversationForMe(outsiderId, conversationId)).rejects.toThrow(
|
||||
'You are not a member of this conversation',
|
||||
);
|
||||
expect(chatRepository.hideConversationForUser).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user