Skip to content

Commit

Permalink
removed test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bhupesh-mfsi committed Sep 9, 2024
1 parent e8f2d90 commit 2385756
Showing 1 changed file with 0 additions and 127 deletions.
127 changes: 0 additions & 127 deletions packages/messenger-widget/src/hooks/messages/useMessage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,134 +90,7 @@ describe('useMessage hook test cases', () => {
...DEFAULT_DM3_CONFIGURATION,
},
});
const config: DM3Configuration = configurationContext.dm3Configuration!;

it('should not add empty message', async () => {
const storageContext = getMockedStorageContext({
editMessageBatchAsync: jest.fn(),
storeMessageBatch: jest.fn(),
storeMessage: jest.fn(),
});
const conversationContext = getMockedConversationContext({
selectedContact: getEmptyContact(
'max.eth',
undefined,
false,
0,
[],
),
});
const deliveryServiceContext = getMockedDeliveryServiceContext({
//Add websocket mock
onNewMessage: (cb: Function) => {
console.log('on new message');
},
removeOnNewMessageListener: jest.fn(),
});
const authContext = getMockedAuthContext({});
const tldContext = getMockedTldContext({});

const wrapper = ({ children }: { children: any }) => (
<>
<AuthContext.Provider value={authContext}>
<TLDContext.Provider value={tldContext}>
<StorageContext.Provider value={storageContext}>
<ConversationContext.Provider
value={conversationContext}
>
<DeliveryServiceContext.Provider
value={deliveryServiceContext}
>
{children}
</DeliveryServiceContext.Provider>
</ConversationContext.Provider>
</StorageContext.Provider>
</TLDContext.Provider>
</AuthContext.Provider>
</>
);

const { result } = renderHook(() => useMessage(), {
wrapper,
});
await waitFor(() =>
expect(result.current.contactIsLoading('max.eth')).toBe(false),
);

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

expect(addMessageResult).toEqual({
isSuccess: false,
error: 'Message is empty',
});
});
it('should trim message', async () => {
const storageContext = getMockedStorageContext({
editMessageBatchAsync: jest.fn(),
storeMessageBatch: jest.fn(),
storeMessage: jest.fn(),
});
const conversationContext = getMockedConversationContext({
selectedContact: getEmptyContact(
'max.eth',
undefined,
false,
0,
[],
),
});
const deliveryServiceContext = getMockedDeliveryServiceContext({
//Add websocket mock
onNewMessage: (cb: Function) => {
console.log('on new message');
},
removeOnNewMessageListener: jest.fn(),
});
const authContext = getMockedAuthContext({});
const tldContext = getMockedTldContext({});

const wrapper = ({ children }: { children: any }) => (
<>
<AuthContext.Provider value={authContext}>
<TLDContext.Provider value={tldContext}>
<StorageContext.Provider value={storageContext}>
<ConversationContext.Provider
value={conversationContext}
>
<DeliveryServiceContext.Provider
value={deliveryServiceContext}
>
{children}
</DeliveryServiceContext.Provider>
</ConversationContext.Provider>
</StorageContext.Provider>
</TLDContext.Provider>
</AuthContext.Provider>
</>
);

const { result } = renderHook(() => useMessage(), {
wrapper,
});
await waitFor(() =>
expect(result.current.contactIsLoading('max.eth')).toBe(false),
);

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

expect(addMessageResult).toEqual({
isSuccess: false,
error: 'Message is empty',
});
});
it('should add message', async () => {
const storageContext = getMockedStorageContext({
editMessageBatchAsync: jest.fn(),
Expand Down

0 comments on commit 2385756

Please sign in to comment.