@@ -81,22 +81,22 @@ describe('GlobalSearchContainer', () => {
81
81
expect ( mockedFetchVenueList ) . toHaveBeenCalled ( ) ;
82
82
} ) ;
83
83
84
- test ( 'shows no choices when search is too short' , ( ) => {
84
+ test ( 'shows no choices when search is too short' , async ( ) => {
85
85
const { getByRole, queryAllByRole } = make ( ) ;
86
86
87
87
// Expect not to show choices when search string is too short
88
- userEvent . type ( getByRole ( 'textbox' ) , '1' ) ;
88
+ await userEvent . type ( getByRole ( 'textbox' ) , '1' ) ;
89
89
expect ( queryAllByRole ( 'option' ) ) . toHaveLength ( 0 ) ;
90
90
91
91
// Expect to show choices when search string is long enough
92
- userEvent . type ( getByRole ( 'textbox' ) , '1' ) ;
92
+ await userEvent . type ( getByRole ( 'textbox' ) , '1' ) ;
93
93
expect ( queryAllByRole ( 'option' ) ) . not . toHaveLength ( 0 ) ;
94
94
} ) ;
95
95
96
- test ( 'shows at most 10 choices when there are many venues and modules' , ( ) => {
96
+ test ( 'shows at most 10 choices when there are many venues and modules' , async ( ) => {
97
97
const { getByRole, getAllByRole } = make ( ) ;
98
98
// Space is intentional - min chars needed to trigger search is 2, so you need an additional character.
99
- userEvent . type ( getByRole ( 'textbox' ) , '1 ' ) ;
99
+ await userEvent . type ( getByRole ( 'textbox' ) , '1 ' ) ;
100
100
expect ( getAllByRole ( 'option' ) . map ( ( elem ) => elem . textContent ) ) . toMatchInlineSnapshot ( `
101
101
[
102
102
"View All Courses",
@@ -115,11 +115,11 @@ describe('GlobalSearchContainer', () => {
115
115
` ) ;
116
116
} ) ;
117
117
118
- test ( 'prioritize showing venues when there are many venues even if there are modules' , ( ) => {
118
+ test ( 'prioritize showing venues when there are many venues even if there are modules' , async ( ) => {
119
119
const { getByRole, getAllByRole } = make ( {
120
120
moduleBank : { moduleList : MODULES . slice ( 0 , 5 ) } ,
121
121
} ) ;
122
- userEvent . type ( getByRole ( 'textbox' ) , '1 ' ) ;
122
+ await userEvent . type ( getByRole ( 'textbox' ) , '1 ' ) ;
123
123
expect ( getAllByRole ( 'option' ) . map ( ( elem ) => elem . textContent ) ) . toMatchInlineSnapshot ( `
124
124
[
125
125
"View All Venues",
@@ -153,11 +153,11 @@ describe('GlobalSearchContainer', () => {
153
153
` ) ;
154
154
} ) ;
155
155
156
- test ( 'shows at most 10 choices when there are many modules' , ( ) => {
156
+ test ( 'shows at most 10 choices when there are many modules' , async ( ) => {
157
157
const { getByRole, getAllByRole } = make ( {
158
158
venueBank : { venueList : VENUES . slice ( 0 , 2 ) } ,
159
159
} ) ;
160
- userEvent . type ( getByRole ( 'textbox' ) , '1 ' ) ;
160
+ await userEvent . type ( getByRole ( 'textbox' ) , '1 ' ) ;
161
161
expect ( getAllByRole ( 'option' ) . map ( ( elem ) => elem . textContent ) ) . toMatchInlineSnapshot ( `
162
162
[
163
163
"View All Courses",
@@ -176,9 +176,9 @@ describe('GlobalSearchContainer', () => {
176
176
` ) ;
177
177
} ) ;
178
178
179
- test ( 'shows all results when there are few' , ( ) => {
179
+ test ( 'shows all results when there are few' , async ( ) => {
180
180
const { getByRole, getAllByRole } = make ( ) ;
181
- userEvent . type ( getByRole ( 'textbox' ) , 'AA' ) ;
181
+ await userEvent . type ( getByRole ( 'textbox' ) , 'AA' ) ;
182
182
expect ( getAllByRole ( 'option' ) . map ( ( elem ) => elem . textContent ) ) . toMatchInlineSnapshot ( `
183
183
[
184
184
"View All Courses",
@@ -189,12 +189,12 @@ describe('GlobalSearchContainer', () => {
189
189
` ) ;
190
190
} ) ;
191
191
192
- test ( 'show many results if the search only returns modules' , ( ) => {
192
+ test ( 'show many results if the search only returns modules' , async ( ) => {
193
193
const { getByRole, getAllByRole } = make ( {
194
194
venueBank : { venueList : range ( 100 ) . map ( ( n ) => `Venue ${ n } ` ) } ,
195
195
} ) ;
196
196
197
- userEvent . type ( getByRole ( 'textbox' ) , '1010' ) ;
197
+ await userEvent . type ( getByRole ( 'textbox' ) , '1010' ) ;
198
198
expect ( getAllByRole ( 'option' ) . map ( ( elem ) => elem . textContent ) ) . toMatchInlineSnapshot ( `
199
199
[
200
200
"View All Courses",
@@ -272,12 +272,12 @@ describe('GlobalSearchContainer', () => {
272
272
` ) ;
273
273
} ) ;
274
274
275
- test ( 'show many results if the search only returns venues' , ( ) => {
275
+ test ( 'show many results if the search only returns venues' , async ( ) => {
276
276
const { getByRole, getAllByRole } = make ( {
277
277
venueBank : { venueList : range ( 100 ) . map ( ( n ) => `Venue ${ n } ` ) } ,
278
278
} ) ;
279
279
280
- userEvent . type ( getByRole ( 'textbox' ) , 'venue' ) ;
280
+ await userEvent . type ( getByRole ( 'textbox' ) , 'venue' ) ;
281
281
expect ( getAllByRole ( 'option' ) . map ( ( elem ) => elem . textContent ) ) . toMatchInlineSnapshot ( `
282
282
[
283
283
"View All Venues",
0 commit comments