Skip to content

Commit

Permalink
refactor test loaders
Browse files Browse the repository at this point in the history
  • Loading branch information
narthur committed Aug 8, 2023
1 parent 1bb87b6 commit 16cb408
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 73 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 37 additions & 67 deletions src/containers/search/index.spec.tsx
Original file line number Diff line number Diff line change
@@ -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');

Expand All @@ -47,58 +38,37 @@ const empty = {
},
};

const loadRecordings = buildLoader<GetSearchRecordingsQuery>(
GetSearchRecordingsDocument,
{
sermons: empty,
}
);
const loadRecordings = buildGetSearchRecordingsLoader({
sermons: empty,
});

const loadSeries = buildLoader<GetSearchSeriesQuery>(GetSearchSeriesDocument, {
const loadSeries = buildGetSearchSeriesLoader({
serieses: empty,
});

const loadConferences = buildLoader<GetSearchConferencesQuery>(
GetSearchConferencesDocument,
{
conferences: empty,
}
);

const loadSponsors = buildLoader<GetSearchSponsorsQuery>(
GetSearchSponsorsDocument,
{
sponsors: empty,
}
);

const loadPersons = buildLoader<GetSearchPersonsQuery>(
GetSearchPersonsDocument,
{
persons: empty,
}
);

const loadAudiobooks = buildLoader<GetSearchAudiobooksQuery>(
GetSearchAudiobooksDocument,
{
audiobooks: empty,
}
);

const loadMusicTracks = buildLoader<GetSearchMusicTracksQuery>(
GetSearchMusicTracksDocument,
{
musicTracks: empty,
}
);

const loadStoryPrograms = buildLoader<GetSearchStoryProgramsQuery>(
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(() => {
Expand Down

0 comments on commit 16cb408

Please sign in to comment.