From 16cb4088fcc088934f243f5df644597807fd484b Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Tue, 8 Aug 2023 10:39:08 -0400 Subject: [PATCH] refactor test loaders --- package-lock.json | 12 ++-- src/containers/search/index.spec.tsx | 104 ++++++++++----------------- 2 files changed, 43 insertions(+), 73 deletions(-) diff --git a/package-lock.json b/package-lock.json index 961982605..b4dc57cb0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9645,9 +9645,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001515", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001515.tgz", - "integrity": "sha512-eEFDwUOZbE24sb+Ecsx3+OvNETqjWIdabMy52oOkIgcUtAsQifjUG9q4U9dgTHJM2mfk4uEPxc0+xuFdJ629QA==", + "version": "1.0.30001519", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001519.tgz", + "integrity": "sha512-0QHgqR+Jv4bxHMp8kZ1Kn8CH55OikjKJ6JmKkZYP1F3D7w+lnFXF70nG5eNfsZS89jadi5Ywy5UCSKLAglIRkg==", "funding": [ { "type": "opencollective", @@ -30731,9 +30731,9 @@ "dev": true }, "caniuse-lite": { - "version": "1.0.30001515", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001515.tgz", - "integrity": "sha512-eEFDwUOZbE24sb+Ecsx3+OvNETqjWIdabMy52oOkIgcUtAsQifjUG9q4U9dgTHJM2mfk4uEPxc0+xuFdJ629QA==" + "version": "1.0.30001519", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001519.tgz", + "integrity": "sha512-0QHgqR+Jv4bxHMp8kZ1Kn8CH55OikjKJ6JmKkZYP1F3D7w+lnFXF70nG5eNfsZS89jadi5Ywy5UCSKLAglIRkg==" }, "capital-case": { "version": "1.0.4", diff --git a/src/containers/search/index.spec.tsx b/src/containers/search/index.spec.tsx index 9391d97da..1d5ddd461 100644 --- a/src/containers/search/index.spec.tsx +++ b/src/containers/search/index.spec.tsx @@ -1,31 +1,22 @@ import { screen, waitFor } from '@testing-library/react'; import { __loadQuery } from 'next/router'; -import { - GetSearchAudiobooksDocument, - GetSearchAudiobooksQuery, - GetSearchConferencesDocument, - GetSearchConferencesQuery, - GetSearchMusicTracksDocument, - GetSearchMusicTracksQuery, - GetSearchPersonsDocument, - GetSearchPersonsQuery, - GetSearchRecordingsDocument, - GetSearchRecordingsQuery, - GetSearchSeriesDocument, - GetSearchSeriesQuery, - GetSearchSponsorsDocument, - GetSearchSponsorsQuery, - GetSearchStoryProgramsDocument, - GetSearchStoryProgramsQuery, -} from '~components/organisms/__generated__/searchResults'; -import { buildLoader } from '~lib/test/buildLoader'; import { buildRenderer } from '~lib/test/buildRenderer'; import Search, { getStaticPaths, getStaticProps, } from '~pages/[language]/search'; import { RecordingContentType } from '~src/__generated__/graphql'; +import { + buildGetSearchAudiobooksLoader, + buildGetSearchConferencesLoader, + buildGetSearchMusicTracksLoader, + buildGetSearchPersonsLoader, + buildGetSearchRecordingsLoader, + buildGetSearchSeriesLoader, + buildGetSearchSponsorsLoader, + buildGetSearchStoryProgramsLoader, +} from '~src/__generated__/loaders'; jest.mock('next/head'); @@ -47,58 +38,37 @@ const empty = { }, }; -const loadRecordings = buildLoader( - GetSearchRecordingsDocument, - { - sermons: empty, - } -); +const loadRecordings = buildGetSearchRecordingsLoader({ + sermons: empty, +}); -const loadSeries = buildLoader(GetSearchSeriesDocument, { +const loadSeries = buildGetSearchSeriesLoader({ serieses: empty, }); -const loadConferences = buildLoader( - GetSearchConferencesDocument, - { - conferences: empty, - } -); - -const loadSponsors = buildLoader( - GetSearchSponsorsDocument, - { - sponsors: empty, - } -); - -const loadPersons = buildLoader( - GetSearchPersonsDocument, - { - persons: empty, - } -); - -const loadAudiobooks = buildLoader( - GetSearchAudiobooksDocument, - { - audiobooks: empty, - } -); - -const loadMusicTracks = buildLoader( - GetSearchMusicTracksDocument, - { - musicTracks: empty, - } -); - -const loadStoryPrograms = buildLoader( - GetSearchStoryProgramsDocument, - { - storyPrograms: empty, - } -); +const loadConferences = buildGetSearchConferencesLoader({ + conferences: empty, +}); + +const loadSponsors = buildGetSearchSponsorsLoader({ + sponsors: empty, +}); + +const loadPersons = buildGetSearchPersonsLoader({ + persons: empty, +}); + +const loadAudiobooks = buildGetSearchAudiobooksLoader({ + audiobooks: empty, +}); + +const loadMusicTracks = buildGetSearchMusicTracksLoader({ + musicTracks: empty, +}); + +const loadStoryPrograms = buildGetSearchStoryProgramsLoader({ + storyPrograms: empty, +}); describe('search', () => { beforeEach(() => {