Use snapshot test

pull/7556/merge
Wei Zhu 7 years ago
parent eb62c44564
commit 2437ca419e

@ -0,0 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Icon should render to a <i class="xxx"></i> 1`] = `
<i
class="anticon anticon-appstore my-icon-classname"
/>
`;

@ -1,28 +1,12 @@
import React from 'react'; import React from 'react';
import TestUtils from 'react-dom/test-utils'; import { render } from 'enzyme';
import Icon from '..'; import Icon from '..';
class Wrapper extends React.Component {
render() {
return this.props.children;
}
}
describe('Icon', () => { describe('Icon', () => {
let icon;
let iconNode;
beforeEach(() => {
icon = TestUtils.renderIntoDocument(
<Wrapper><Icon type="appstore" className="my-icon-classname" /></Wrapper>
);
iconNode = TestUtils.findRenderedDOMComponentWithTag(icon, 'I');
});
it('should render to a <i class="xxx"></i>', () => { it('should render to a <i class="xxx"></i>', () => {
expect(iconNode.tagName).toBe('I'); const wrapper = render(
expect(iconNode.className).toContain('my-icon-classname'); <Icon type="appstore" className="my-icon-classname" />
expect(iconNode.className).toContain('anticon'); );
expect(iconNode.className).toContain('anticon-appstore'); expect(wrapper).toMatchSnapshot();
}); });
}); });

Loading…
Cancel
Save