Skip to content

Instantly share code, notes, and snippets.

@productioncoder
Last active December 2, 2018 15:54
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 productioncoder/6213d7341156c62b056ec680d0ae8a67 to your computer and use it in GitHub Desktop.
Save productioncoder/6213d7341156c62b056ec680d0ae8a67 to your computer and use it in GitHub Desktop.
Snapshot testing components with different props
import React from 'react';
import {shallow} from 'enzyme';
import {SideBarHeader} from '../SideNavHeader';
describe('SideBarHeader', () => {
test('renders SideBarHeader with props.title=null', () => {
const wrapper = shallow(
<SideBarHeader/>
);
expect(wrapper).toMatchSnapshot();
});
test('renders SideBarHeader with props.title=\'\'', () => {
const wrapper = shallow(
<SideBarHeader title=''/>
);
expect(wrapper).toMatchSnapshot();
});
test('renders SideBarHeader with sample title', () => {
const wrapper = shallow(
<SideBarHeader title='Sample Title'/>
);
expect(wrapper).toMatchSnapshot();
});
});
import React from 'react';
import {shallow} from 'enzyme';
import {Subscription} from '../Subscription';
describe('Subscription', () => {
test('renders empty subscription', () => {
const wrapper = shallow(
<Subscription/>
);
expect(wrapper).toMatchSnapshot();
});
test('renders broadcasting subscription', () => {
const wrapper = shallow(
<Subscription broadcasting label='Productioncoder'/>
);
expect(wrapper).toMatchSnapshot();
});
test('renders non-broadcasting subscription with new videos', () => {
const wrapper = shallow(
<Subscription amountNewVideos={4} label='Productioncoder'/>
);
expect(wrapper).toMatchSnapshot();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment