Skip to content

Instantly share code, notes, and snippets.

@rodoabad
Last active March 6, 2020 03:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rodoabad/fe5f03e48214c4714685d662d65d11c5 to your computer and use it in GitHub Desktop.
Save rodoabad/fe5f03e48214c4714685d662d65d11c5 to your computer and use it in GitHub Desktop.
import {CommentList} from '../CommentList';
import React from 'react';
import {shallow} from 'enzyme';
describe('Given the <CommentList/> component', () => {
const requiredProps = () => ({});
const render = (props = requiredProps()) => shallow(<CommentList {...props} />);
test('should render', () => {
const wrapper = render();
expect(wrapper).toHaveLength(1);
});
test('should show some text if there are no comments', () => {
const expectedText = 'No comments yet';
const wrapper = render();
expect(wrapper.text()).toStrictEqual(expectedText);
});
test('should show a loading indicator if comments are loading', () => {
const expectedText = 'Loading';
const props = {
...requiredProps(),
isLoading: true
};
const wrapper = render(props);
expect(wrapper.text()).toStrictEqual(expectedText);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment