Skip to content

Commit

Permalink
fix: unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
abretonc7s committed Aug 27, 2024
1 parent 34af96a commit 70f3b76
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { setupChannelListeners } from './setupChannelListeners';
jest.mock('./setupChannelListeners');

const mockConnect = jest.fn();
const mockEmit = jest.fn();
const mockEmit = jest.fn((_event, _payload, callback) => {
callback(null, { ready: true }); // Simulate successful emit
});
const mockGetMyPublicKey = jest.fn();

describe('createChannel', () => {
Expand Down Expand Up @@ -67,11 +69,15 @@ describe('createChannel', () => {
it('should emit JOIN_CHANNEL event with correct parameters', async () => {
const result = await createChannel(instance);

expect(instance.state.socket?.emit).toHaveBeenCalledWith('join_channel', {
channelId: instance.state.channelId,
clientType: 'dapp',
context: 'testContextcreateChannel',
});
expect(instance.state.socket?.emit).toHaveBeenCalledWith(
'join_channel',
{
channelId: instance.state.channelId,
clientType: 'dapp',
context: 'testContextcreateChannel',
},
expect.any(Function), // Match the callback function
);

expect(result.pubKey).toBe('');
});
Expand Down

0 comments on commit 70f3b76

Please sign in to comment.