diff --git a/app/soapbox/api/hooks/groups/__tests__/usePendingGroups.test.ts b/app/soapbox/api/hooks/groups/__tests__/usePendingGroups.test.ts index c30516962..c5b85fe28 100644 --- a/app/soapbox/api/hooks/groups/__tests__/usePendingGroups.test.ts +++ b/app/soapbox/api/hooks/groups/__tests__/usePendingGroups.test.ts @@ -1,15 +1,32 @@ import { __stub } from 'soapbox/api'; -import { buildGroup } from 'soapbox/jest/factory'; +import { Entities } from 'soapbox/entity-store/entities'; +import { buildAccount, buildGroup } from 'soapbox/jest/factory'; import { renderHook, waitFor } from 'soapbox/jest/test-helpers'; import { normalizeInstance } from 'soapbox/normalizers'; import { usePendingGroups } from '../usePendingGroups'; -const group = buildGroup({ id: '1', display_name: 'soapbox' }); +const id = '1'; +const group = buildGroup({ id, display_name: 'soapbox' }); const store = { instance: normalizeInstance({ version: '3.4.1 (compatible; TruthSocial 1.0.0+unreleased)', }), + me: '1', + entities: { + [Entities.ACCOUNTS]: { + store: { + [id]: buildAccount({ + id, + acct: 'tiger', + display_name: 'Tiger', + avatar: 'test.jpg', + verified: true, + }), + }, + lists: {}, + }, + }, }; describe('usePendingGroups hook', () => { diff --git a/app/soapbox/api/hooks/groups/usePendingGroups.ts b/app/soapbox/api/hooks/groups/usePendingGroups.ts index f7b6b4cef..f4ea16a43 100644 --- a/app/soapbox/api/hooks/groups/usePendingGroups.ts +++ b/app/soapbox/api/hooks/groups/usePendingGroups.ts @@ -9,7 +9,7 @@ function usePendingGroups() { const features = useFeatures(); const { entities, ...result } = useEntities( - [Entities.GROUPS, account?.id as string, 'pending'], + [Entities.GROUPS, account?.id!, 'pending'], () => api.get('/api/v1/groups', { params: { pending: true, @@ -17,7 +17,7 @@ function usePendingGroups() { }), { schema: groupSchema, - enabled: features.groupsPending, + enabled: !!account && features.groupsPending, }, );