Add some tests

This commit is contained in:
afc163 2018-03-23 19:19:29 +08:00
parent ba7b7d0d6b
commit 07d6988f0d
5 changed files with 98 additions and 0 deletions

View File

@ -214,3 +214,29 @@ exports[`Cascader popup correctly with defaultValue 1`] = `
</div>
</div>
`;
exports[`Cascader support controlled mode 1`] = `
<span
class="ant-cascader-picker"
tabindex="0"
>
<span
class="ant-cascader-picker-label"
>
Zhejiang / Hangzhou / West Lake
</span>
<input
autocomplete="off"
class="ant-input ant-cascader-input "
readonly=""
type="text"
value=""
/>
<i
class="anticon anticon-cross-circle ant-cascader-picker-clear"
/>
<i
class="anticon anticon-down ant-cascader-picker-arrow"
/>
</span>
`;

View File

@ -46,6 +46,16 @@ describe('Cascader', () => {
expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot();
});
it('support controlled mode', () => {
const wrapper = mount(
<Cascader options={options} />
);
wrapper.setProps({
value: ['zhejiang', 'hangzhou', 'xihu'],
});
expect(wrapper.render()).toMatchSnapshot();
});
it('popup correctly with defaultValue', () => {
const wrapper = mount(
<Cascader options={options} defaultValue={['zhejiang', 'hangzhou']} />

View File

@ -0,0 +1,4 @@
import InputNumber from '..';
import focusTest from '../../../tests/shared/focusTest';
focusTest(InputNumber);

View File

@ -0,0 +1,43 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Slider should show tooltip when hovering slider handler 1`] = `
<div>
<div
class="ant-tooltip ant-tooltip-placement-top "
>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
/>
<div
class="ant-tooltip-inner"
>
30
</div>
</div>
</div>
</div>
`;
exports[`Slider should show tooltip when hovering slider handler 2`] = `
<div>
<div
class="ant-tooltip ant-tooltip-placement-top ant-tooltip-hidden"
>
<div
class="ant-tooltip-content"
>
<div
class="ant-tooltip-arrow"
/>
<div
class="ant-tooltip-inner"
>
30
</div>
</div>
</div>
</div>
`;

View File

@ -0,0 +1,15 @@
import React from 'react';
import { render, mount } from 'enzyme';
import Slider from '..';
describe('Slider', () => {
it('should show tooltip when hovering slider handler', () => {
const wrapper = mount(
<Slider defaultValue={30} />
);
wrapper.find('.ant-slider-handle').at(0).simulate('mouseEnter');
expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot();
wrapper.find('.ant-slider-handle').at(0).simulate('mouseLeave');
expect(render(wrapper.find('Trigger').instance().getComponent())).toMatchSnapshot();
});
});