Download wp-calypso/client/components/forms/form-country-select/test/index.jsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.33 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/forms/form-country-select/test/index.jsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/components/forms/form-country-select/test/index.jsx
-
curl -L -o index.jsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/components/forms/form-country-select/test/index.jsx
1.33 kB
| /** | |
| * @jest-environment jsdom | |
| */ | |
| import { render } from '@testing-library/react'; | |
| import { FormCountrySelect } from 'calypso/components/forms/form-country-select'; | |
| describe( 'FormCountrySelect', () => { | |
| const translate = ( string ) => string; | |
| test( 'should render a select box with a placeholder when the country list provided is empty', () => { | |
| const { container } = render( | |
| <FormCountrySelect countriesList={ [] } translate={ translate } /> | |
| ); | |
| const options = container.getElementsByTagName( 'option' ); | |
| expect( options ).toHaveLength( 1 ); | |
| expect( options[ 0 ].textContent ).toEqual( 'Loading…' ); | |
| } ); | |
| test( 'should render a select box with options matching the country list provided', () => { | |
| const { container } = render( | |
| <FormCountrySelect | |
| countriesList={ [ | |
| { | |
| code: 'US', | |
| name: 'United States (+1)', | |
| numeric_code: '+1', | |
| country_name: 'United States', | |
| }, | |
| { | |
| code: 'AR', | |
| name: 'Argentina (+54)', | |
| numeric_code: '+54', | |
| country_name: 'Argentina', | |
| }, | |
| ] } | |
| translate={ translate } | |
| /> | |
| ); | |
| const options = container.getElementsByTagName( 'option' ); | |
| expect( options ).toHaveLength( 2 ); | |
| expect( options[ 0 ].value ).toEqual( 'US' ); | |
| expect( options[ 0 ].textContent ).toEqual( 'United States (+1)' ); | |
| } ); | |
| } ); | |