forked from BloomTech-Labs/Labs28-Bridges-D-FE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHome.test.js
42 lines (38 loc) · 1.09 KB
/
Home.test.js
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
42
import React from 'react';
import { render, cleanup, wait, waitFor } from '@testing-library/react';
import { HomePage } from '../components/pages/Home';
import { LoadingComponent } from '../components/common';
import { BrowserRouter as Router } from 'react-router-dom';
afterEach(cleanup);
jest.mock('@okta/okta-react', () => ({
useOktaAuth: () => {
return {
authState: {
isAuthenticated: true,
},
authService: {
getUser: () => Promise.resolve({ name: 'sara' }),
},
};
},
}));
describe('<HomeContainer /> testing suite', () => {
test('mounts a page', async () => {
const { findByText, getByText, queryByText } = render(
<Router>
<HomePage
LoadingComponent={() => (
<LoadingComponent message="...fetching profile" />
)}
/>
</Router>
);
let loader = getByText(/...fetching profile/i);
expect(loader).toBeInTheDocument();
await waitFor(async () => {
await findByText(/hi sara/i);
});
loader = queryByText(/...fetching profile/i);
expect(loader).toBeNull();
});
});