-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathuseMessageList.test.jsx
41 lines (36 loc) · 1.26 KB
/
useMessageList.test.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import React from 'react';
import { SessionContext } from '@contexts';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { describe, expect, it, vi } from 'vitest';
import { renderHook, waitFor } from '@testing-library/react';
import { useMessageList } from '@hooks';
import { getSolidDataset, mockSolidDatasetFrom } from '@inrupt/solid-client';
vi.mock('@inrupt/solid-client');
const queryClient = new QueryClient({
defaultOptions: {
queries: {
retry: false
}
}
});
const sessionInfo = {
session: {
info: {
isLoggedIn: true,
webId: 'https://example.com/test/profile/card#me'
}
}
};
const wrapper = ({ children }) => (
<QueryClientProvider client={queryClient}>
<SessionContext.Provider value={sessionInfo}>{children}</SessionContext.Provider>
</QueryClientProvider>
);
describe('useMessageList', () => {
it('Returns inbox list if list is found, but an empty list when 0 messages', async () => {
getSolidDataset.mockResolvedValue(mockSolidDatasetFrom('https://example.com/test/PASS/Inbox/'));
const { result } = renderHook(() => useMessageList('Inbox'), { wrapper });
await waitFor(() => expect(result.current.isSuccess).toBe(true));
expect(result.current.data).toStrictEqual([]);
});
});