* Set default styles and move button style out of form * Add MVP of Preact /settings/integrations * Change background color on hover and focus * Remove unused constructor * Improve optimistic rendering * Add display name * Use loading indicator for optimistic rendering * WIP test * Add basic snapshot tests
34 lines
1 KiB
JavaScript
34 lines
1 KiB
JavaScript
import { h } from 'preact';
|
|
import { shallow } from 'preact-render-spy';
|
|
import render from 'preact-render-to-json';
|
|
import fetch from 'jest-fetch-mock';
|
|
import { GithubRepos } from '../githubRepos';
|
|
|
|
global.fetch = fetch;
|
|
|
|
describe('<GithubRepos />', () => {
|
|
describe('when there are no repos loaded yet', () => {
|
|
it('should render and match the snapshot', () => {
|
|
const tree = render(<GithubRepos />);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
|
|
it('should have the loading div', () => {
|
|
const context = shallow(<GithubRepos />);
|
|
expect(context.find('.loading-repos')[0].attributes.className).toEqual(
|
|
'github-repos loading-repos',
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('when there was an error in the response', () => {
|
|
it('renders and matches the snapshot', () => {
|
|
fetch.mockReject('some error');
|
|
const context = shallow(<GithubRepos />);
|
|
context.setState({ erroredOut: true });
|
|
context.rerender();
|
|
const tree = render(context);
|
|
expect(tree).toMatchSnapshot();
|
|
});
|
|
});
|
|
});
|