Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.