@@ -5,12 +5,12 @@ import userEvent from '@testing-library/user-event';
5
5
6
6
describe ( 'Popover' , ( ) => {
7
7
const popoverTestId = 'popoverTestId' ;
8
+ const popoverListTestId = 'popoverListTestId' ;
8
9
const triggerLabel = 'Popover trigger' ;
9
- const navLabel = 'Test list' ;
10
10
const popover = (
11
11
< Popover testId = { popoverTestId } >
12
12
< Popover . Trigger > { triggerLabel } </ Popover . Trigger >
13
- < Popover . List ariaLabel = { navLabel } >
13
+ < Popover . List testId = { popoverListTestId } >
14
14
< Popover . ListItem href = "" > List item 1</ Popover . ListItem >
15
15
< Popover . ListItem href = "" > List item 2</ Popover . ListItem >
16
16
< Popover . ListItem href = "" > List item 3</ Popover . ListItem >
@@ -25,7 +25,7 @@ describe('Popover', () => {
25
25
const popoverTrigger = screen . getByRole ( 'button' , {
26
26
name : triggerLabel
27
27
} ) ;
28
- const popoverList = screen . getByRole ( 'navigation' , { name : navLabel } ) ;
28
+ const popoverList = screen . getByTestId ( popoverListTestId ) ;
29
29
30
30
expect ( popoverWrapper ) . toBeInTheDocument ( ) ;
31
31
expect ( popoverTrigger ) . toBeInTheDocument ( ) ;
@@ -37,9 +37,7 @@ describe('Popover', () => {
37
37
const button = await screen . findByRole ( 'button' , {
38
38
name : triggerLabel
39
39
} ) ;
40
- const dropdown = await screen . findByRole ( 'navigation' , {
41
- name : navLabel
42
- } ) ;
40
+ const dropdown = screen . getByTestId ( popoverListTestId ) ;
43
41
44
42
userEvent . click ( button ) ;
45
43
expect ( dropdown . classList ) . toContain ( 'popover--expanded' ) ;
@@ -54,9 +52,7 @@ describe('Popover', () => {
54
52
const button = await screen . findByRole ( 'button' , {
55
53
name : triggerLabel
56
54
} ) ;
57
- const dropdown = await screen . findByRole ( 'navigation' , {
58
- name : navLabel
59
- } ) ;
55
+ const dropdown = screen . getByTestId ( popoverListTestId ) ;
60
56
61
57
userEvent . click ( document . body ) ;
62
58
expect ( dropdown . classList ) . not . toContain ( 'popover--expanded' ) ;
@@ -73,9 +69,7 @@ describe('Popover', () => {
73
69
const button = await screen . findByRole ( 'button' , {
74
70
name : triggerLabel
75
71
} ) ;
76
- const dropdown = await screen . findByRole ( 'navigation' , {
77
- name : navLabel
78
- } ) ;
72
+ const dropdown = screen . getByTestId ( popoverListTestId ) ;
79
73
const externalButton = await screen . findByRole ( 'button' , {
80
74
name : 'External button'
81
75
} ) ;
@@ -106,9 +100,7 @@ describe('Popover', () => {
106
100
const button = await screen . findByRole ( 'button' , {
107
101
name : triggerLabel
108
102
} ) ;
109
- const dropdown = await screen . findByRole ( 'navigation' , {
110
- name : navLabel
111
- } ) ;
103
+ const dropdown = screen . getByTestId ( popoverListTestId ) ;
112
104
const externalButton = await screen . findByRole ( 'button' , {
113
105
name : 'External button'
114
106
} ) ;
0 commit comments