2020-08-12 10:22:21 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import Space from '..';
|
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
|
|
|
|
|
|
|
describe('Space', () => {
|
|
|
|
mountTest(Space);
|
|
|
|
|
|
|
|
it('should render width empty children', () => {
|
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return <Space />;
|
|
|
|
},
|
|
|
|
});
|
2020-08-12 14:08:06 +00:00
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
2020-08-12 10:22:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render width customize size', () => {
|
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Space size={10}>
|
|
|
|
<span>1</span>
|
|
|
|
<span>2</span>
|
|
|
|
</Space>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
2021-07-06 02:07:48 +00:00
|
|
|
expect(wrapper.findAll('.ant-space-item')[0].element.style.marginRight).toBe('10px');
|
|
|
|
expect(wrapper.findAll('.ant-space-item')[1].element.style.marginRight).toBe('');
|
2020-08-12 10:22:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render vertical space width customize size', () => {
|
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Space size={10} direction="vertical">
|
|
|
|
<span>1</span>
|
|
|
|
<span>2</span>
|
|
|
|
</Space>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
2021-07-06 02:07:48 +00:00
|
|
|
expect(wrapper.findAll('.ant-space-item')[0].element.style.marginBottom).toBe('10px');
|
|
|
|
expect(wrapper.findAll('.ant-space-item')[1].element.style.marginBottom).toBe('');
|
2020-08-12 10:22:21 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it('should render correct with children', () => {
|
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Space>
|
|
|
|
text1<span>text1</span>
|
|
|
|
text3
|
|
|
|
</Space>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper.html()).toMatchSnapshot();
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should render with invalidElement', () => {
|
|
|
|
const wrapper = mount({
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<Space>
|
|
|
|
text1<span>text1</span>
|
|
|
|
text1
|
|
|
|
</Space>
|
|
|
|
);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
expect(wrapper.findAll('.ant-space-item').length).toBe(3);
|
|
|
|
});
|
|
|
|
});
|