Skip to content

Commit bfd0222

Browse files
committed
fix: failing faulty test
1 parent a433f6c commit bfd0222

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

package/src/components/Channel/__tests__/Channel.test.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ describe('Channel initial load useEffect', () => {
356356
cleanup();
357357
});
358358

359-
it('should not call channel.watch if channel is not initialized', async () => {
359+
it('should still call channel.watch if we are online and DB channels are loaded', async () => {
360360
const messages = Array.from({ length: 10 }, (_, i) => generateMessage({ id: i }));
361361
const mockedChannel = generateChannelResponse({
362362
messages,
@@ -366,13 +366,18 @@ describe('Channel initial load useEffect', () => {
366366
const channel = chatClient.channel('messaging', mockedChannel.id);
367367
await channel.watch();
368368
channel.offlineMode = true;
369-
channel.state = channelInitialState;
369+
channel.state = {
370+
...channelInitialState,
371+
messagePagination: {
372+
hasPrev: true,
373+
},
374+
};
370375
const watchSpy = jest.fn();
371376
channel.watch = watchSpy;
372377

373378
renderComponent({ channel });
374379

375-
await waitFor(() => expect(watchSpy).not.toHaveBeenCalled());
380+
await waitFor(() => expect(watchSpy).toHaveBeenCalledTimes(1));
376381
});
377382

378383
it("should call channel.watch if channel is initialized and it's not in offline mode", async () => {

0 commit comments

Comments
 (0)