File size: 1,804 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
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();
});
});
|