From f2dc9b35f44d9025e315d7e3e33b758a95eb7cda Mon Sep 17 00:00:00 2001 From: riteshrana12-dev Date: Fri, 1 May 2026 02:26:14 +0530 Subject: [PATCH] test(common): add missing test coverage for useLikePlays hook --- .../hooks/__tests__/useLikePlays.test.js | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/common/hooks/__tests__/useLikePlays.test.js b/src/common/hooks/__tests__/useLikePlays.test.js index 8e819d312..10746cd26 100644 --- a/src/common/hooks/__tests__/useLikePlays.test.js +++ b/src/common/hooks/__tests__/useLikePlays.test.js @@ -53,4 +53,31 @@ describe('useLikePlays', () => { await expect(result.current.unLikePlay({ play_id: 'abc' })).rejects.toThrow('Delete failed'); }); + + it('likePlay calls likeIndividualPlay with correct argument', async () => { + const { likeIndividualPlay } = jest.requireMock('common/services/request/query/like-play'); + submit.mockResolvedValueOnce({}); + + const { result } = renderHook(() => useLikePlays()); + await result.current.likePlay({ play_id: 'abc' }); + + expect(likeIndividualPlay).toHaveBeenCalledWith({ play_id: 'abc' }); + }); + + it('unLikePlay calls unlikeIndividualPlay with correct argument', async () => { + const { unlikeIndividualPlay } = jest.requireMock('common/services/request/query/like-play'); + submit.mockResolvedValueOnce({}); + + const { result } = renderHook(() => useLikePlays()); + await result.current.unLikePlay({ play_id: 'xyz' }); + + expect(unlikeIndividualPlay).toHaveBeenCalledWith({ play_id: 'xyz' }); + }); + + it('hook returns likePlay and unLikePlay functions', () => { + const { result } = renderHook(() => useLikePlays()); + + expect(typeof result.current.likePlay).toBe('function'); + expect(typeof result.current.unLikePlay).toBe('function'); + }); });