Fix useFetchRelationships tests

This commit is contained in:
Alex Gleason 2023-01-05 18:05:55 -06:00
parent edbaf60009
commit e83914482d
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -30,7 +30,7 @@ describe('useFetchRelationships()', () => {
}); });
it('is successful', async() => { it('is successful', async() => {
const { result } = renderHook(() => { renderHook(() => {
const fetchRelationships = useFetchRelationships(); const fetchRelationships = useFetchRelationships();
useEffect(() => { useEffect(() => {
@ -40,13 +40,13 @@ describe('useFetchRelationships()', () => {
return fetchRelationships; return fetchRelationships;
}, undefined, store); }, undefined, store);
await waitFor(() => expect(result.current.isLoading).toBe(false)); await waitFor(() => {
expect(store.getState().relationships.size).toBe(1); expect(store.getState().relationships.size).toBe(1);
expect(store.getState().relationships.getIn([id, 'id'])).toBe(id); expect(store.getState().relationships.getIn([id, 'id'])).toBe(id);
expect(store.getState().relationships.getIn([id, 'blocked_by'])).toBe(true); expect(store.getState().relationships.getIn([id, 'blocked_by'])).toBe(true);
}); });
}); });
});
describe('with multiple relationships', () => { describe('with multiple relationships', () => {
const ids = ['123', '456']; const ids = ['123', '456'];
@ -60,7 +60,7 @@ describe('useFetchRelationships()', () => {
}); });
it('is successful', async() => { it('is successful', async() => {
const { result } = renderHook(() => { renderHook(() => {
const fetchRelationships = useFetchRelationships(); const fetchRelationships = useFetchRelationships();
useEffect(() => { useEffect(() => {
@ -70,14 +70,14 @@ describe('useFetchRelationships()', () => {
return fetchRelationships; return fetchRelationships;
}, undefined, store); }, undefined, store);
await waitFor(() => expect(result.current.isLoading).toBe(false)); await waitFor(() => {
expect(store.getState().relationships.size).toBe(2); expect(store.getState().relationships.size).toBe(2);
expect(store.getState().relationships.getIn([ids[0], 'id'])).toBe(ids[0]); expect(store.getState().relationships.getIn([ids[0], 'id'])).toBe(ids[0]);
expect(store.getState().relationships.getIn([ids[1], 'id'])).toBe(ids[1]); expect(store.getState().relationships.getIn([ids[1], 'id'])).toBe(ids[1]);
}); });
}); });
}); });
});
describe('with an unsuccessful query', () => { describe('with an unsuccessful query', () => {
const id = '123'; const id = '123';