|
@ -1,5 +1,5 @@ |
|
|
import React, { Component } from 'react'; |
|
|
import React, { Component } from 'react'; |
|
|
import { render, mount } from 'enzyme'; |
|
|
import { mount } from 'enzyme'; |
|
|
import renderer from 'react-test-renderer'; |
|
|
import renderer from 'react-test-renderer'; |
|
|
import { SearchOutlined } from '@ant-design/icons'; |
|
|
import { SearchOutlined } from '@ant-design/icons'; |
|
|
import Button from '..'; |
|
|
import Button from '..'; |
|
@ -26,8 +26,7 @@ describe('Button', () => { |
|
|
rtlTest(() => <Button.Group size="middle" />); |
|
|
rtlTest(() => <Button.Group size="middle" />); |
|
|
|
|
|
|
|
|
it('renders correctly', () => { |
|
|
it('renders correctly', () => { |
|
|
const wrapper = render(<Button>Follow</Button>); |
|
|
expect(<Button>Follow</Button>).toMatchRenderedSnapshot(); |
|
|
expect(wrapper).toMatchSnapshot(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('mount correctly', () => { |
|
|
it('mount correctly', () => { |
|
@ -45,40 +44,33 @@ describe('Button', () => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('renders Chinese characters correctly', () => { |
|
|
it('renders Chinese characters correctly', () => { |
|
|
const wrapper = render(<Button>按钮</Button>); |
|
|
expect(<Button>按钮</Button>).toMatchRenderedSnapshot(); |
|
|
expect(wrapper).toMatchSnapshot(); |
|
|
|
|
|
// should not insert space when there is icon
|
|
|
// should not insert space when there is icon
|
|
|
const wrapper1 = render(<Button icon={<SearchOutlined />}>按钮</Button>); |
|
|
expect(<Button icon={<SearchOutlined />}>按钮</Button>).toMatchRenderedSnapshot(); |
|
|
expect(wrapper1).toMatchSnapshot(); |
|
|
|
|
|
// should not insert space when there is icon
|
|
|
// should not insert space when there is icon
|
|
|
const wrapper2 = render( |
|
|
expect( |
|
|
<Button> |
|
|
<Button> |
|
|
<SearchOutlined /> |
|
|
<SearchOutlined /> |
|
|
按钮 |
|
|
按钮 |
|
|
</Button>, |
|
|
</Button>, |
|
|
); |
|
|
).toMatchRenderedSnapshot(); |
|
|
expect(wrapper2).toMatchSnapshot(); |
|
|
|
|
|
// should not insert space when there is icon
|
|
|
// should not insert space when there is icon
|
|
|
const wrapper3 = render(<Button icon={<SearchOutlined />}>按钮</Button>); |
|
|
expect(<Button icon={<SearchOutlined />}>按钮</Button>).toMatchRenderedSnapshot(); |
|
|
expect(wrapper3).toMatchSnapshot(); |
|
|
|
|
|
// should not insert space when there is icon while loading
|
|
|
// should not insert space when there is icon while loading
|
|
|
const wrapper4 = render( |
|
|
expect( |
|
|
<Button icon={<SearchOutlined />} loading> |
|
|
<Button icon={<SearchOutlined />} loading> |
|
|
按钮 |
|
|
按钮 |
|
|
</Button>, |
|
|
</Button>, |
|
|
); |
|
|
).toMatchRenderedSnapshot(); |
|
|
expect(wrapper4).toMatchSnapshot(); |
|
|
|
|
|
// should insert space while loading
|
|
|
// should insert space while loading
|
|
|
const wrapper5 = render(<Button loading>按钮</Button>); |
|
|
expect(<Button loading>按钮</Button>).toMatchRenderedSnapshot(); |
|
|
expect(wrapper5).toMatchSnapshot(); |
|
|
|
|
|
|
|
|
|
|
|
// should insert space while only one nested element
|
|
|
// should insert space while only one nested element
|
|
|
const wrapper6 = render( |
|
|
expect( |
|
|
<Button> |
|
|
<Button> |
|
|
<span>按钮</span> |
|
|
<span>按钮</span> |
|
|
</Button>, |
|
|
</Button>, |
|
|
); |
|
|
).toMatchRenderedSnapshot(); |
|
|
expect(wrapper6).toMatchSnapshot(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('renders Chinese characters correctly in HOC', () => { |
|
|
it('renders Chinese characters correctly in HOC', () => { |
|
@ -103,8 +95,7 @@ describe('Button', () => { |
|
|
|
|
|
|
|
|
// https://github.com/ant-design/ant-design/issues/18118
|
|
|
// https://github.com/ant-design/ant-design/issues/18118
|
|
|
it('should not insert space to link button', () => { |
|
|
it('should not insert space to link button', () => { |
|
|
const wrapper = render(<Button type="link">按钮</Button>); |
|
|
expect(<Button type="link">按钮</Button>).toMatchRenderedSnapshot(); |
|
|
expect(wrapper).toMatchSnapshot(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should render empty button without errors', () => { |
|
|
it('should render empty button without errors', () => { |
|
@ -191,12 +182,9 @@ describe('Button', () => { |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('fixbug renders {0} , 0 and {false}', () => { |
|
|
it('fixbug renders {0} , 0 and {false}', () => { |
|
|
const wrapper = render(<Button>{0}</Button>); |
|
|
expect(<Button>{0}</Button>).toMatchRenderedSnapshot(); |
|
|
expect(wrapper).toMatchSnapshot(); |
|
|
expect(<Button>0</Button>).toMatchRenderedSnapshot(); |
|
|
const wrapper1 = render(<Button>0</Button>); |
|
|
expect(<Button>{false}</Button>).toMatchRenderedSnapshot(); |
|
|
expect(wrapper1).toMatchSnapshot(); |
|
|
|
|
|
const wrapper2 = render(<Button>{false}</Button>); |
|
|
|
|
|
expect(wrapper2).toMatchSnapshot(); |
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
it('should has click wave effect', async () => { |
|
|
it('should has click wave effect', async () => { |
|
|