Download react-boilerplate/app/components/ReposList/tests/index.test.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-boilerplate/app/components/ReposList/tests/index.test.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/react-boilerplate/app/components/ReposList/tests/index.test.js
-
curl -L -o index.test.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/react-boilerplate/app/components/ReposList/tests/index.test.js
1.8 kB
| import React from 'react'; | |
| import { IntlProvider } from 'react-intl'; | |
| import { Provider } from 'react-redux'; | |
| import { browserHistory } from 'react-router-dom'; | |
| import { render } from 'react-testing-library'; | |
| import ReposList from '../index'; | |
| import configureStore from '../../../configureStore'; | |
| describe('<ReposList />', () => { | |
| it('should render the loading indicator when its loading', () => { | |
| const { container } = render(<ReposList loading />); | |
| expect(container.firstChild).toMatchSnapshot(); | |
| }); | |
| it('should render an error if loading failed', () => { | |
| const { queryByText } = render( | |
| <IntlProvider locale="en"> | |
| <ReposList loading={false} error={{ message: 'Loading failed!' }} /> | |
| </IntlProvider>, | |
| ); | |
| expect(queryByText(/Something went wrong/)).not.toBeNull(); | |
| }); | |
| it('should render the repositories if loading was successful', () => { | |
| const store = configureStore( | |
| { global: { currentUser: 'mxstbr' } }, | |
| browserHistory, | |
| ); | |
| const repos = [ | |
| { | |
| owner: { | |
| login: 'mxstbr', | |
| }, | |
| html_url: 'https://github.com/react-boilerplate/react-boilerplate', | |
| name: 'react-boilerplate', | |
| open_issues_count: 20, | |
| full_name: 'react-boilerplate/react-boilerplate', | |
| }, | |
| ]; | |
| const { container } = render( | |
| <Provider store={store}> | |
| <IntlProvider locale="en"> | |
| <ReposList repos={repos} error={false} /> | |
| </IntlProvider> | |
| </Provider>, | |
| ); | |
| expect(container.firstChild).toMatchSnapshot(); | |
| }); | |
| it('should not render anything if nothing interesting is provided', () => { | |
| const { container } = render( | |
| <ReposList repos={false} error={false} loading={false} />, | |
| ); | |
| expect(container.firstChild).toBeNull(); | |
| }); | |
| }); | |