|
1 |
| -import '@testing-library/jest-dom' // this should go in ./src/setupTests.js |
| 1 | +import '@testing-library/jest-dom' |
2 | 2 | import { render, screen } from '@testing-library/react'
|
3 | 3 | import userEvent from '@testing-library/user-event'
|
4 | 4 | import exampleData from '../data.json'
|
5 |
| -import AutoFillDropDown from './AutoFillDropDown' |
| 5 | +import EmployerDropDown from './EmployerDropDown' |
6 | 6 |
|
7 |
| -describe('AutoFillDropDown', () => { |
8 |
| - describe('AutoFillDropDown', () => { |
9 |
| - it('shows a matching option for specific word', async () => { |
10 |
| - const user = userEvent.setup() |
11 |
| - render( |
12 |
| - <AutoFillDropDown |
13 |
| - arrayList={exampleData.employerList} |
14 |
| - employerOnChange={() => {}} |
15 |
| - isEmpty={false} |
16 |
| - label="Employer" |
17 |
| - name="employer" |
18 |
| - /> |
19 |
| - ) |
| 7 | +describe('EmployerDropDown', () => { |
| 8 | + it('shows a matching option for specific word', async () => { |
| 9 | + const user = userEvent.setup() |
| 10 | + render( |
| 11 | + <EmployerDropDown |
| 12 | + arrayList={exampleData.employerList} |
| 13 | + employerOnChange={() => {}} |
| 14 | + isEmpty={false} |
| 15 | + /> |
| 16 | + ) |
20 | 17 |
|
21 |
| - await user.type( |
22 |
| - screen.getByRole('textbox', { name: /employer/i }), |
23 |
| - 'capgemini' |
24 |
| - ) |
| 18 | + await user.type(screen.getByRole('textbox', { name: /employer/i }), 'cap') |
25 | 19 |
|
26 |
| - expect( |
27 |
| - screen.getByRole('option', { name: /capgemini/i }) |
28 |
| - ).toBeInTheDocument() |
29 |
| - }) |
30 | 20 | expect(
|
31 |
| - screen.queryByRole('option', { name: /Carnall Farrar/i }) |
32 |
| - ).not.toBeInTheDocument() |
| 21 | + screen.getByRole('option', { name: /capgemini/i }) |
| 22 | + ).toBeInTheDocument() |
33 | 23 | })
|
| 24 | + expect( |
| 25 | + screen.queryByRole('option', { name: /Carnall Farrar/i }) |
| 26 | + ).not.toBeInTheDocument() |
34 | 27 | it('finds characters within words', async () => {
|
35 | 28 | const user = userEvent.setup()
|
36 | 29 | render(
|
37 |
| - <AutoFillDropDown |
| 30 | + <EmployerDropDown |
38 | 31 | arrayList={exampleData.employerList}
|
39 | 32 | employerOnChange={() => {}}
|
40 | 33 | isEmpty={false}
|
41 |
| - name="employer" |
42 |
| - label="Employer" |
43 | 34 | />
|
44 | 35 | )
|
45 | 36 |
|
|
0 commit comments