55} from '@codecademy/gamut-icons' ;
66import { setupRtl } from '@codecademy/gamut-tests' ;
77import { fireEvent , queryByAttribute } from '@testing-library/dom' ;
8- import { waitFor } from '@testing-library/react' ;
98import { act } from 'react' ;
109
1110import { SelectDropdown } from '../SelectDropdown' ;
@@ -74,11 +73,6 @@ const openDropdown = async (view: ReturnType<typeof renderView>['view']) => {
7473 } ) ;
7574} ;
7675
77- const getById = queryByAttribute . bind ( null , 'id' ) ;
78-
79- const getMenuList = ( view : ReturnType < typeof renderView > [ 'view' ] ) =>
80- getById ( view . container , / l i s t b o x / ) ?. firstChild ;
81-
8276describe ( 'SelectDropdown' , ( ) => {
8377 it ( 'sets the id prop on the select tag' , ( ) => {
8478 const { view } = renderView ( ) ;
@@ -112,30 +106,22 @@ describe('SelectDropdown', () => {
112106 view . getByTitle ( 'Arrow Chevron Down Icon' ) ;
113107 } ) ;
114108
115- // TO-DO: Fix these tests
116-
117- it . skip ( 'renders a dropdown with the correct maxHeight when shownOptionsLimit is specified' , async ( ) => {
109+ it ( 'renders a dropdown with the correct maxHeight when shownOptionsLimit is specified' , async ( ) => {
118110 const { view } = renderView ( { shownOptionsLimit : 4 } ) ;
119111
120112 await openDropdown ( view ) ;
121113
122- const menuList = getMenuList ( view ) ;
123-
124- expect ( menuList ) . toHaveStyle ( '' ) ;
114+ expect ( view . getByRole ( 'listbox' ) ) . toHaveStyle ( { maxHeight : '12rem' } ) ;
125115 } ) ;
126-
127- // TO-DO: Fix these test
128- it . skip ( 'renders a dropdown with the correct maxHeight when shownOptionsLimit is specified + size is "small"' , async ( ) => {
116+ it ( 'renders a dropdown with the correct maxHeight when shownOptionsLimit is specified + size is "small"' , async ( ) => {
129117 const { view } = renderView ( {
130118 size : 'small' ,
131119 shownOptionsLimit : 4 ,
132120 } ) ;
133121
134122 await openDropdown ( view ) ;
135123
136- const menuList = getMenuList ( view ) ;
137-
138- expect ( menuList ) . toHaveStyle ( { maxHeight : '8rem' } ) ;
124+ expect ( view . getByRole ( 'listbox' ) ) . toHaveStyle ( { maxHeight : '8rem' } ) ;
139125 } ) ;
140126
141127 it ( 'renders a dropdown with icons' , async ( ) => {
@@ -157,17 +143,17 @@ describe('SelectDropdown', () => {
157143 expect ( onInputChange ) . toHaveBeenCalled ( ) ;
158144 } ) ;
159145
160- it . skip ( 'renders selected & multiple items when passed multiple: true' , async ( ) => {
146+ it ( 'renders selected & multiple items when passed multiple: true' , async ( ) => {
161147 const { view } = renderView ( { multiple : true } ) ;
162148
163149 const numSelectedItems = 2 ;
164150
165151 const multiple = selectOptions . map ( async ( opt ) => {
166152 await openDropdown ( view ) ;
167153
168- await waitFor ( ( ) => view . getByText ( opt ) ) ;
154+ const option = await view . findByText ( opt ) ;
169155 await act ( ( ) => {
170- fireEvent . click ( view . getByText ( opt ) ) ;
156+ fireEvent . click ( option ) ;
171157 return Promise . resolve ( ) ;
172158 } ) ;
173159 } ) ;
0 commit comments