From bd4c99b697d622f4e490807059db5edcf71d2205 Mon Sep 17 00:00:00 2001 From: Chewbacca Date: Wed, 8 Mar 2023 14:11:40 -0500 Subject: [PATCH] Fix tests --- .../hooks/__tests__/useGroupsPath.test.ts | 23 +++++++------------ app/soapbox/queries/groups.ts | 6 ++--- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/app/soapbox/hooks/__tests__/useGroupsPath.test.ts b/app/soapbox/hooks/__tests__/useGroupsPath.test.ts index de123d211..c3ec1e169 100644 --- a/app/soapbox/hooks/__tests__/useGroupsPath.test.ts +++ b/app/soapbox/hooks/__tests__/useGroupsPath.test.ts @@ -2,7 +2,7 @@ import { Map as ImmutableMap } from 'immutable'; import { __stub } from 'soapbox/api'; import { renderHook, waitFor } from 'soapbox/jest/test-helpers'; -import { normalizeAccount, normalizeGroup, normalizeInstance } from 'soapbox/normalizers'; +import { normalizeAccount, normalizeGroup, normalizeGroupRelationship, normalizeInstance } from 'soapbox/normalizers'; import { useGroupsPath } from '../useGroupsPath'; @@ -58,23 +58,16 @@ describe('useGroupsPath()', () => { id: '1', }), ]); + + mock.onGet('/api/v1/groups/relationships?id[]=1').reply(200, [ + normalizeGroupRelationship({ + id: '1', + }), + ]); }); }); - test('should default to the discovery page', async () => { - const store = { - entities: { - Groups: { - store: { - '1': normalizeGroup({}), - }, - lists: { - '': new Set(['1']), - }, - }, - }, - }; - + test('should default to the "My Groups" page', async () => { const { result } = renderHook(useGroupsPath, undefined, store); await waitFor(() => { diff --git a/app/soapbox/queries/groups.ts b/app/soapbox/queries/groups.ts index 32b4189c4..93fb23661 100644 --- a/app/soapbox/queries/groups.ts +++ b/app/soapbox/queries/groups.ts @@ -104,7 +104,7 @@ const usePopularGroups = () => { const { fetchGroups } = useGroupsApi(); const getQuery = async () => { - const { groups } = await fetchGroups('/api/v1/groups/search?q=group'); // '/api/v1/truth/trends/groups' + const { groups } = await fetchGroups('/api/v1/truth/trends/groups'); return groups; }; @@ -125,7 +125,7 @@ const useSuggestedGroups = () => { const { fetchGroups } = useGroupsApi(); const getQuery = async () => { - const { groups } = await fetchGroups('/api/v1/groups/search?q=group'); // /api/v1/truth/suggestions/groups + const { groups } = await fetchGroups('/api/v1/truth/suggestions/groups'); return groups; }; @@ -146,7 +146,7 @@ const useGroup = (id: string) => { const { fetchGroups } = useGroupsApi(); const getGroup = async () => { - const { groups } = await fetchGroups(`/api/v1/groups/${id}`); // /api/v1/truth/suggestions/groups + const { groups } = await fetchGroups(`/api/v1/groups/${id}`); return groups[0]; };