-
-
Notifications
You must be signed in to change notification settings - Fork 206
/
Copy pathAwaitingApproval.test.tsx
42 lines (37 loc) · 1.4 KB
/
AwaitingApproval.test.tsx
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, fireEvent, screen } from '@testing-library/react';
import AwaitingApproval from '../../app/components/AwaitingApproval';
import '@testing-library/jest-dom';
// THE FILE THAT IS BEING TESTED IS NOT BEING USED
jest.mock('react-router', () => ({
// ...jest.requireActual('react-router-dom') as typeof ReactRouterDom,
useHistory: () => ({ push: jest.fn() }), // ({ push: jest.fn() })
}));
describe('Awaiting Approval Page', () => {
// renders the componenet before evey test
beforeEach(() => {
render(<AwaitingApproval />);
});
it('Should have awaiting approval message', () => {
const element = screen.getByText(/awaiting approval/i);
expect(element).toBeInTheDocument()
// console.log("ELEMENT:", element);
// expect(element).toMatchInlineSnapshot(`
// <p
// class="welcomeMessage"
// data-testid="awaitingApprovalMessage"
// >
// Your account is awaiting approval. Please contact your administrator if you have any questions.
// </p>
// `);
});
it('Should have return button', () => {
const returnBtn = screen.getByRole('button');
expect(returnBtn).toHaveTextContent('Return');
});
it('Should perform re-route on button click', () => {
const returnBtn = screen.getByRole('button');
expect(fireEvent.click(returnBtn)).toBeTruthy();
expect(typeof returnBtn.onclick).toBe('function');
});
});