|
1 | 1 | import React from 'react' |
2 | 2 | import { render, screen } from 'src/utilities/testingLibrary' |
3 | | -import { act } from 'react' |
4 | 3 | import { InstitutionTile } from '../InstitutionTile' |
| 4 | +import { InstitutionStatusField } from 'src/utilities/institutionStatus' |
5 | 5 |
|
6 | 6 | describe('<InstitutionTile />', () => { |
7 | | - it('renders the logoUrl in the src if there is one', async () => { |
| 7 | + it('renders the logoUrl in the src if there is one', () => { |
8 | 8 | const institution = { |
9 | 9 | name: 'testName', |
10 | 10 | logo_url: 'testLogoUrl', |
11 | 11 | } |
12 | 12 |
|
13 | | - await act(async () => { |
14 | | - render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) |
15 | | - }) |
| 13 | + render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) |
16 | 14 |
|
17 | 15 | expect(screen.getByAltText(`${institution.name} logo`)).toHaveAttribute( |
18 | 16 | 'src', |
19 | 17 | institution.logo_url, |
20 | 18 | ) |
21 | 19 | }) |
22 | 20 |
|
23 | | - it('renders a generated url with the guid if there is no logoUrl', async () => { |
| 21 | + it('renders a generated url with the guid if there is no logoUrl', () => { |
24 | 22 | const institution = { |
25 | 23 | guid: 'testGuid', |
26 | 24 | name: 'testName', |
27 | 25 | } |
28 | 26 |
|
29 | | - await act(async () => { |
30 | | - render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) |
31 | | - }) |
| 27 | + render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) |
32 | 28 |
|
33 | 29 | expect(screen.getByAltText(`${institution.name} logo`).src.includes(institution.guid)).toBe( |
34 | 30 | true, |
35 | 31 | ) |
36 | 32 | }) |
37 | 33 |
|
38 | | - it('renders a disabled Chip if the institution is disabled', async () => { |
| 34 | + it('renders a disabled Chip if the institution is disabled', () => { |
39 | 35 | const institution = { |
40 | 36 | guid: 'testGuid', |
41 | 37 | name: 'testName', |
42 | 38 | is_disabled_by_client: true, |
43 | 39 | } |
44 | 40 |
|
45 | | - await act(async () => { |
46 | | - render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) |
47 | | - }) |
| 41 | + render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) |
48 | 42 |
|
49 | 43 | expect(screen.getByText('DISABLED')).toBeInTheDocument() |
50 | 44 | }) |
51 | 45 |
|
52 | | - it('does not render a disabled Chip if the institution is not disabled', async () => { |
| 46 | + it('does not render a disabled Chip if the institution is not disabled', () => { |
53 | 47 | const institution = { |
54 | 48 | guid: 'testGuid', |
55 | 49 | name: 'testName', |
56 | 50 | is_disabled_by_client: false, |
57 | 51 | } |
58 | 52 |
|
59 | | - await act(async () => { |
60 | | - render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) |
61 | | - }) |
| 53 | + render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) |
62 | 54 |
|
63 | 55 | expect(screen.queryByText('DISABLED')).not.toBeInTheDocument() |
64 | 56 | }) |
| 57 | + |
| 58 | + it('renders an UNAVAILABLE Chip if the institution is unavailable by experiment values', () => { |
| 59 | + const institution = { guid: 'testGuid', name: 'testName' } |
| 60 | + const preloadedState = { |
| 61 | + experimentalFeatures: { |
| 62 | + unavailableInstitutions: [institution], |
| 63 | + }, |
| 64 | + } |
| 65 | + |
| 66 | + render(<InstitutionTile institution={institution} selectInstitution={() => {}} />, { |
| 67 | + preloadedState, |
| 68 | + }) |
| 69 | + |
| 70 | + expect(screen.getByText('UNAVAILABLE')).toBeInTheDocument() |
| 71 | + }) |
| 72 | + |
| 73 | + it('renders an UNAVAILABLE Chip if the institution is unavailable by API', () => { |
| 74 | + const institution = { |
| 75 | + guid: 'testGuid', |
| 76 | + name: 'testName', |
| 77 | + status: InstitutionStatusField.UNAVAILABLE, |
| 78 | + } |
| 79 | + |
| 80 | + render(<InstitutionTile institution={institution} selectInstitution={() => {}} />) |
| 81 | + |
| 82 | + expect(screen.getByText('UNAVAILABLE')).toBeInTheDocument() |
| 83 | + }) |
65 | 84 | }) |
0 commit comments