From 751b0bb9e5da55838102f6ef6f73e0c94d59a21f Mon Sep 17 00:00:00 2001 From: Robert Skinner Date: Sun, 24 Sep 2023 22:20:22 -0500 Subject: [PATCH] fix test --- .../{VideoHook.test.js => UseVideoDataFetcher.test.js} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename __tests__/hooks/{VideoHook.test.js => UseVideoDataFetcher.test.js} (95%) diff --git a/__tests__/hooks/VideoHook.test.js b/__tests__/hooks/UseVideoDataFetcher.test.js similarity index 95% rename from __tests__/hooks/VideoHook.test.js rename to __tests__/hooks/UseVideoDataFetcher.test.js index 76a6226..d2545f9 100644 --- a/__tests__/hooks/VideoHook.test.js +++ b/__tests__/hooks/UseVideoDataFetcher.test.js @@ -1,7 +1,7 @@ import { renderHook, act } from "@testing-library/react-hooks"; import axios from 'axios'; import AppConstants from '../../src/AppConstants'; -import useVideoHook from "../../src/hooks/VideoHook"; +import useVideoDataFetcher from "../../src/hooks/UseVideoDataFetcher"; jest.mock('axios'); @@ -15,7 +15,7 @@ const testVideos = [ } ]; const mockResponse = { - data: { + data: { songs: testVideos } }; @@ -27,7 +27,7 @@ describe('useVideoHook', () => { // call the hook using renderHook (it requires a component) const initialPlaylistIds = []; - const { result, waitForNextUpdate } = renderHook(() => useVideoHook(initialPlaylistIds)); + const { result, waitForNextUpdate } = renderHook(() => useVideoDataFetcher(initialPlaylistIds)); expect(axios.post).toHaveBeenCalledWith(AppConstants.APIEndpoints.SHUFFLE, { playlist_ids: initialPlaylistIds }); // expect hook state to have been initialized @@ -53,7 +53,7 @@ describe('useVideoHook', () => { dispatchFunction(updatedPlaylistIds); }) expect(axios.post).toHaveBeenCalledWith(AppConstants.APIEndpoints.SHUFFLE, { playlist_ids: updatedPlaylistIds }); - + // expect hook state to have been initialized hookResult = result.current[0]; expect(hookResult.videos).toEqual([]);