Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNi245 committed Sep 9, 2024
1 parent 2677898 commit 95caef7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 6 additions & 5 deletions packages/messenger-widget/src/hooks/messages/useMessage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ describe('useMessage hook test cases', () => {
});
const config: DM3Configuration = configurationContext.dm3Configuration!;

it('should not add empty message', async () => {
it('should add message', async () => {
const storageContext = getMockedStorageContext({
editMessageBatchAsync: jest.fn(),
storeMessageBatch: jest.fn(),
Expand Down Expand Up @@ -145,15 +145,16 @@ describe('useMessage hook test cases', () => {
);

const messageFactory = MockMessageFactory(sender, receiver, ds1);
const message = await messageFactory.createMessage('');
const message = await messageFactory.createMessage('hello dm3');
const addMessageResult = await waitFor(() =>
result.current.addMessage('max.eth', message),
result.current.addMessage('alice.eth', message),
);

expect(addMessageResult).toEqual({
isSuccess: false,
error: 'Message is empty',
isSuccess: true,
error: undefined,
});
expect(result.current.messages['alice.eth'].length).toBe(1);
});
it('should send message to ds', async () => {
axiosMock = new MockAdapter(axios);
Expand Down
2 changes: 0 additions & 2 deletions packages/messenger-widget/src/hooks/messages/useMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,6 @@ export const useMessage = () => {
message: Message,
): Promise<{ isSuccess: boolean; error?: string }> => {
const contact = normalizeEnsName(_contactName);
//If a message is empty it should not be added

//Find the recipient of the message in the contact list
const recipient = contacts.find(
(c) => c.contactDetails.account.ensName === contact,
Expand Down

0 comments on commit 95caef7

Please sign in to comment.