mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-02 03:59:01 +08:00
Restructure tests.
This commit is contained in:
parent
764cd9439d
commit
17a0a33283
@ -10,9 +10,9 @@
|
||||
],
|
||||
"transform": {
|
||||
"\\.tsx?$": "node_modules/typescript-babel-jest",
|
||||
"tests/.*\\.js$": "node_modules/babel-jest",
|
||||
"\\.js$": "node_modules/babel-jest",
|
||||
"\\.md$": "node_modules/antd-demo-jest"
|
||||
},
|
||||
"testRegex": "/tests/.*demo\\.test\\.js$",
|
||||
"testRegex": "demo\\.test\\.js$",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
|
199
components/cascader/__tests__/__snapshots__/demo.test.js.snap
Normal file
199
components/cascader/__tests__/__snapshots__/demo.test.js.snap
Normal file
@ -0,0 +1,199 @@
|
||||
exports[`test renders ./components/cascader/demo/basic.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-cascader-picker">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input "
|
||||
placeholder="Please select"
|
||||
readonly=""
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`test renders ./components/cascader/demo/change-on-select.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-cascader-picker">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input "
|
||||
placeholder="Please select"
|
||||
readonly=""
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`test renders ./components/cascader/demo/custom-render.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-cascader-picker"
|
||||
style="width:270px;">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input "
|
||||
readonly=""
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label">
|
||||
<span>
|
||||
Zhejiang /
|
||||
</span>
|
||||
<span>
|
||||
Hangzhou /
|
||||
</span>
|
||||
<span>
|
||||
West Lake (
|
||||
<a>
|
||||
752100
|
||||
</a>
|
||||
)
|
||||
</span>
|
||||
</span>
|
||||
<i
|
||||
class="anticon anticon-cross-circle ant-cascader-picker-clear" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`test renders ./components/cascader/demo/custom-trigger.md correctly 1`] = `
|
||||
<span>
|
||||
Unselect
|
||||
<a
|
||||
href="#">
|
||||
Change city
|
||||
</a>
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`test renders ./components/cascader/demo/default-value.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-cascader-picker">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input "
|
||||
readonly=""
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label">
|
||||
Zhejiang / Hangzhou / West Lake
|
||||
</span>
|
||||
<i
|
||||
class="anticon anticon-cross-circle ant-cascader-picker-clear" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`test renders ./components/cascader/demo/disabled-option.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-cascader-picker">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input "
|
||||
placeholder="Please select"
|
||||
readonly=""
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`test renders ./components/cascader/demo/hover.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-cascader-picker">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input "
|
||||
placeholder="Please select"
|
||||
readonly=""
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`test renders ./components/cascader/demo/search.md correctly 1`] = `
|
||||
<span
|
||||
class="ant-cascader-picker">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input "
|
||||
placeholder="Please select"
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
`;
|
||||
|
||||
exports[`test renders ./components/cascader/demo/size.md correctly 1`] = `
|
||||
<div>
|
||||
<span
|
||||
class="ant-cascader-picker">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input ant-input-lg"
|
||||
placeholder="Please select"
|
||||
readonly=""
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
<br />
|
||||
<br />
|
||||
<span
|
||||
class="ant-cascader-picker">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input "
|
||||
placeholder="Please select"
|
||||
readonly=""
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
<br />
|
||||
<br />
|
||||
<span
|
||||
class="ant-cascader-picker">
|
||||
<input
|
||||
autocomplete="off"
|
||||
class="ant-input ant-cascader-input ant-input-sm"
|
||||
placeholder="Please select"
|
||||
readonly=""
|
||||
type="text"
|
||||
value="" />
|
||||
<span
|
||||
class="ant-cascader-picker-label" />
|
||||
<i
|
||||
class="anticon anticon-down ant-cascader-picker-arrow" />
|
||||
</span>
|
||||
<br />
|
||||
<br />
|
||||
</div>
|
||||
`;
|
@ -186,10 +186,10 @@
|
||||
],
|
||||
"transform": {
|
||||
"\\.tsx?$": "node_modules/typescript-babel-jest",
|
||||
"tests/.*\\.js$": "node_modules/babel-jest",
|
||||
"\\.js$": "node_modules/babel-jest",
|
||||
"\\.md$": "node_modules/antd-demo-jest"
|
||||
},
|
||||
"testRegex": "/tests/.*\\.test\\.js$",
|
||||
"testRegex": ".*\\.test\\.js$",
|
||||
"collectCoverageFrom": [
|
||||
"components/**/*.{ts,tsx}",
|
||||
"!components/*/style/index.tsx"
|
||||
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('affix');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('alert');
|
@ -1,20 +0,0 @@
|
||||
import React from 'react';
|
||||
import { mount } from 'enzyme';
|
||||
import Anchor from '../../components/anchor';
|
||||
|
||||
const { Link } = Anchor;
|
||||
|
||||
describe('Anchor Render', () => {
|
||||
it('Anchor render perfectly', () => {
|
||||
const wrapper = mount(
|
||||
<Anchor>
|
||||
<Link href="#API" title="API" />
|
||||
</Anchor>
|
||||
);
|
||||
|
||||
wrapper.find('a[href="#API"]').simulate('click');
|
||||
|
||||
wrapper.node.handleScroll();
|
||||
expect(wrapper.node.state).not.toBe(null);
|
||||
});
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('anchor');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('auto-complete');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('back-top');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('badge');
|
@ -1,12 +0,0 @@
|
||||
import { render } from 'enzyme';
|
||||
import { renderToJson } from 'enzyme-to-json';
|
||||
import demoTest from '../shared/demoTest';
|
||||
import routerDemo from '../../components/breadcrumb/demo/router.md';
|
||||
|
||||
demoTest('breadcrumb', { skip: ['router.md'] });
|
||||
|
||||
const testMethod = typeof window !== 'undefined' ? test : test.skip;
|
||||
testMethod('renders ./components/breadcrumb/demo/router.md correctly', () => {
|
||||
const wrapper = render(routerDemo);
|
||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('button');
|
@ -1,20 +0,0 @@
|
||||
import React from 'react';
|
||||
import { render } from 'enzyme';
|
||||
import { renderToJson } from 'enzyme-to-json';
|
||||
import Button from '../../components/button';
|
||||
|
||||
describe('Button', () => {
|
||||
it('renders correctly', () => {
|
||||
const wrapper = render(
|
||||
<Button>Follow</Button>
|
||||
);
|
||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders Chinese characters correctly', () => {
|
||||
const wrapper = render(
|
||||
<Button>按钮</Button>
|
||||
);
|
||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||
});
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('calendar');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('card');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('carousel');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('checkbox');
|
@ -1,23 +0,0 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import Checkbox from '../../components/checkbox';
|
||||
|
||||
describe('Checkbox', () => {
|
||||
it('responses hover events', () => {
|
||||
const onMouseEnter = jest.fn();
|
||||
const onMouseLeave = jest.fn();
|
||||
|
||||
const wrapper = shallow(
|
||||
<Checkbox
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
/>
|
||||
);
|
||||
|
||||
wrapper.simulate('mouseenter');
|
||||
expect(onMouseEnter).toHaveBeenCalled();
|
||||
|
||||
wrapper.simulate('mouseleave');
|
||||
expect(onMouseLeave).toHaveBeenCalled();
|
||||
});
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('collapse');
|
@ -1,14 +0,0 @@
|
||||
import { render } from 'enzyme';
|
||||
import { renderToJson } from 'enzyme-to-json';
|
||||
import MockDate from 'mockdate';
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('date-picker', { skip: ['locale.md'] });
|
||||
|
||||
test('renders ./components/date-picker/demo/locale.md correctly', () => {
|
||||
MockDate.set(new Date('2016-11-22').getTime());
|
||||
const LocaleDemo = require('../../components/date-picker/demo/locale'); // eslint-disable-line global-require
|
||||
const wrapper = render(LocaleDemo);
|
||||
expect(renderToJson(wrapper)).toMatchSnapshot();
|
||||
MockDate.reset();
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('dropdown');
|
@ -1,36 +0,0 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import Dropdown from '../../components/dropdown';
|
||||
import Menu from '../../components/menu';
|
||||
|
||||
describe('DropdownButton', () => {
|
||||
it('pass appropriate props to Dropdown', () => {
|
||||
const props = {
|
||||
align: {
|
||||
offset: [10, 20],
|
||||
},
|
||||
overlay: (
|
||||
<Menu>
|
||||
<Menu.Item>foo</Menu.Item>
|
||||
</Menu>
|
||||
),
|
||||
trigger: ['hover'],
|
||||
visible: true,
|
||||
onVisibleChange: () => {},
|
||||
};
|
||||
|
||||
const wrapper = shallow(<Dropdown.Button {...props} />);
|
||||
const dropdownProps = wrapper.find(Dropdown).props();
|
||||
|
||||
Object.keys(props).forEach((key) => {
|
||||
expect(dropdownProps[key]).toBe(props[key]);
|
||||
});
|
||||
});
|
||||
|
||||
it('don\'t pass visible to Dropdown if it\'s not exits', () => {
|
||||
const wrapper = shallow(<Dropdown.Button />);
|
||||
const dropdownProps = wrapper.find(Dropdown).props();
|
||||
|
||||
expect('visible' in dropdownProps).toBe(false);
|
||||
});
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('form');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('grid');
|
@ -1,25 +0,0 @@
|
||||
import React from 'react';
|
||||
import TestUtils from 'react-addons-test-utils';
|
||||
import { wrap } from 'react-stateless-wrapper';
|
||||
import AntIcon from '../../components/icon/index';
|
||||
|
||||
const Icon = wrap(AntIcon);
|
||||
|
||||
describe('Icon', () => {
|
||||
let icon;
|
||||
let iconNode;
|
||||
|
||||
beforeEach(() => {
|
||||
icon = TestUtils.renderIntoDocument(
|
||||
<Icon type="appstore" className="my-icon-classname" />
|
||||
);
|
||||
iconNode = TestUtils.findRenderedDOMComponentWithTag(icon, 'I');
|
||||
});
|
||||
|
||||
it('should render to a <i class="xxx"></i>', () => {
|
||||
expect(iconNode.tagName).toBe('I');
|
||||
expect(iconNode.className).toContain('my-icon-classname');
|
||||
expect(iconNode.className).toContain('anticon');
|
||||
expect(iconNode.className).toContain('anticon-appstore');
|
||||
});
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('input-number');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('input');
|
@ -1,21 +0,0 @@
|
||||
import React from 'react';
|
||||
import TestUtils from 'react-addons-test-utils';
|
||||
|
||||
const { Col, Row } = require('../../components/grid/index');
|
||||
|
||||
describe('Grid', () => {
|
||||
it('should render Col', () => {
|
||||
const col = TestUtils.renderIntoDocument(
|
||||
<Col span="2" />
|
||||
);
|
||||
const colNode = TestUtils.findRenderedDOMComponentWithTag(col, 'DIV');
|
||||
expect(colNode.className).toBe('ant-col-2');
|
||||
});
|
||||
it('should render Row', () => {
|
||||
const row = TestUtils.renderIntoDocument(
|
||||
<Row />
|
||||
);
|
||||
const rowNode = TestUtils.findRenderedDOMComponentWithTag(row, 'DIV');
|
||||
expect(rowNode.className).toBe('ant-row');
|
||||
});
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('locale-provider');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('mention', { skip: true });
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('menu');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('message');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('modal');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('notification');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('pagination');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('popconfirm');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('popover');
|
@ -1,25 +0,0 @@
|
||||
import React from 'react';
|
||||
import TestUtils from 'react-addons-test-utils';
|
||||
import Popover from '../../components/popover/index';
|
||||
|
||||
describe('Popover', () => {
|
||||
it('should show overlay when trigger is clicked', () => {
|
||||
const popover = TestUtils.renderIntoDocument(
|
||||
<Popover content="console.log('hello world')" title="code" trigger="click">
|
||||
<span>show me your code</span>
|
||||
</Popover>
|
||||
);
|
||||
|
||||
expect(popover.getPopupDomNode()).toBe(null);
|
||||
|
||||
TestUtils.Simulate.click(
|
||||
TestUtils.findRenderedDOMComponentWithTag(popover, 'span')
|
||||
);
|
||||
|
||||
const popup = popover.getPopupDomNode();
|
||||
expect(popup).not.toBe(null);
|
||||
expect(popup.className).toContain('ant-popover-placement-top');
|
||||
expect(popup.innerHTML).toMatch(/<div class="ant-popover-title".*?>code<\/div>/);
|
||||
expect(popup.innerHTML).toMatch(/<div class="ant-popover-inner-content".*?>console\.log\('hello world'\)<\/div>/);
|
||||
});
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('progress');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('radio');
|
@ -1,26 +0,0 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import Radio from '../../components/radio';
|
||||
import RadioGroup from '../../components/radio/group';
|
||||
|
||||
describe('Radio', () => {
|
||||
it('responses hover events', () => {
|
||||
const onMouseEnter = jest.fn();
|
||||
const onMouseLeave = jest.fn();
|
||||
|
||||
const wrapper = shallow(
|
||||
<RadioGroup
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
>
|
||||
<Radio />
|
||||
</RadioGroup>
|
||||
);
|
||||
|
||||
wrapper.simulate('mouseenter');
|
||||
expect(onMouseEnter).toHaveBeenCalled();
|
||||
|
||||
wrapper.simulate('mouseleave');
|
||||
expect(onMouseLeave).toHaveBeenCalled();
|
||||
});
|
||||
});
|
@ -1,23 +0,0 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import Radio from '../../components/radio';
|
||||
|
||||
describe('Radio', () => {
|
||||
it('responses hover events', () => {
|
||||
const onMouseEnter = jest.fn();
|
||||
const onMouseLeave = jest.fn();
|
||||
|
||||
const wrapper = shallow(
|
||||
<Radio
|
||||
onMouseEnter={onMouseEnter}
|
||||
onMouseLeave={onMouseLeave}
|
||||
/>
|
||||
);
|
||||
|
||||
wrapper.simulate('mouseenter');
|
||||
expect(onMouseEnter).toHaveBeenCalled();
|
||||
|
||||
wrapper.simulate('mouseleave');
|
||||
expect(onMouseLeave).toHaveBeenCalled();
|
||||
});
|
||||
});
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('rate');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('select');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('slider');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('spin');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('steps');
|
@ -1,3 +0,0 @@
|
||||
import demoTest from '../shared/demoTest';
|
||||
|
||||
demoTest('switch');
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user