From 2437ca419ed2617544da449fc106436a08ed564d Mon Sep 17 00:00:00 2001 From: Wei Zhu Date: Fri, 15 Sep 2017 10:50:45 +0800 Subject: [PATCH] Use snapshot test --- .../__snapshots__/index.test.js.snap | 7 +++++ components/icon/__tests__/index.test.js | 26 ++++--------------- 2 files changed, 12 insertions(+), 21 deletions(-) create mode 100644 components/icon/__tests__/__snapshots__/index.test.js.snap diff --git a/components/icon/__tests__/__snapshots__/index.test.js.snap b/components/icon/__tests__/__snapshots__/index.test.js.snap new file mode 100644 index 0000000000..0e7a3ec4aa --- /dev/null +++ b/components/icon/__tests__/__snapshots__/index.test.js.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Icon should render to a 1`] = ` + +`; diff --git a/components/icon/__tests__/index.test.js b/components/icon/__tests__/index.test.js index accc18f99c..10eb9c6fb0 100644 --- a/components/icon/__tests__/index.test.js +++ b/components/icon/__tests__/index.test.js @@ -1,28 +1,12 @@ import React from 'react'; -import TestUtils from 'react-dom/test-utils'; +import { render } from 'enzyme'; import Icon from '..'; -class Wrapper extends React.Component { - render() { - return this.props.children; - } -} - describe('Icon', () => { - let icon; - let iconNode; - - beforeEach(() => { - icon = TestUtils.renderIntoDocument( - - ); - iconNode = TestUtils.findRenderedDOMComponentWithTag(icon, 'I'); - }); - it('should render to a ', () => { - expect(iconNode.tagName).toBe('I'); - expect(iconNode.className).toContain('my-icon-classname'); - expect(iconNode.className).toContain('anticon'); - expect(iconNode.className).toContain('anticon-appstore'); + const wrapper = render( + + ); + expect(wrapper).toMatchSnapshot(); }); });