Add account check

This commit is contained in:
Chewbacca 2023-06-29 10:49:37 -04:00
parent cadff9b4ab
commit 241ef58e88
2 changed files with 21 additions and 4 deletions

View file

@ -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', () => {

View file

@ -9,7 +9,7 @@ function usePendingGroups() {
const features = useFeatures();
const { entities, ...result } = useEntities<Group>(
[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,
},
);