Skip to content

Commit

Permalink
test: add testing for gray message deleting
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisamir98 committed Dec 18, 2023
1 parent 4ecfcf6 commit e4e2f84
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/script/conversation/MessageRepository.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {CryptographyRepository} from '../cryptography/CryptographyRepository';
import {ContentMessage} from '../entity/message/ContentMessage';
import {EventRepository} from '../event/EventRepository';
import {EventService} from '../event/EventService';
import {StatusType} from '../message/StatusType';
import {PropertiesRepository} from '../properties/PropertiesRepository';
import {ReactionMap} from '../storage';
import {TeamState} from '../team/TeamState';
Expand Down Expand Up @@ -241,6 +242,25 @@ describe('MessageRepository', () => {
}),
);
});

it('should send delete and deletes message for own pending/gray messages', async () => {
const conversation = generateConversation(CONVERSATION_TYPE.REGULAR);
conversation.participating_user_ets.push(new User('user1'));

const messageToDelete = new Message(createUuid());
messageToDelete.user(selfUser);
messageToDelete.status(StatusType.SENDING);
conversation.addMessage(messageToDelete);

const [messageRepository, {core, eventRepository}] = await buildMessageRepository();
jest.spyOn(core.service!.conversation, 'send').mockResolvedValue(successPayload);
spyOn(eventRepository.eventService, 'deleteEvent').and.returnValue(Promise.resolve());
spyOn(messageRepository, 'deleteMessageById');

await messageRepository.deleteMessageForEveryone(conversation, messageToDelete);

expect(messageRepository.deleteMessageById).toHaveBeenCalledWith(conversation, messageToDelete.id);
});
});

describe('resetSession', () => {
Expand Down

0 comments on commit e4e2f84

Please sign in to comment.