Fix wave render error in jest, close #11868

This commit is contained in:
afc163 2018-08-24 12:11:44 +08:00
parent 68959b9a4f
commit 62bacb09bf
2 changed files with 11 additions and 1 deletions

View File

@ -50,7 +50,9 @@ export default class Wave extends React.Component<{insertExtraNode?: boolean}> {
}
bindAnimationEvent = (node: HTMLElement) => {
if (node.getAttribute('disabled') ||
if (!node ||
!node.getAttribute ||
node.getAttribute('disabled') ||
node.className.indexOf('disabled') >= 0) {
return;
}

View File

@ -1,5 +1,6 @@
import React, { Component } from 'react';
import { render, mount } from 'enzyme';
import renderer from 'react-test-renderer';
import Button from '..';
import Icon from '../../icon';
@ -11,6 +12,13 @@ describe('Button', () => {
expect(wrapper).toMatchSnapshot();
});
it('mount correctly', () => {
const wrapper = mount(
<Button>Follow</Button>
);
expect(() => renderer.create(wrapper).toJSON()).not.toThrow();
});
it('renders Chinese characters correctly', () => {
const wrapper = render(
<Button>按钮</Button>