Restructure tests.

This commit is contained in:
Wei Zhu 2016-12-14 14:41:39 +08:00
parent 764cd9439d
commit 17a0a33283
118 changed files with 203 additions and 1019 deletions

View File

@ -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"
}

View 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>
`;

View File

@ -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"

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('affix');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('alert');

View File

@ -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);
});
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('anchor');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('auto-complete');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('back-top');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('badge');

View File

@ -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();
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('button');

View File

@ -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();
});
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('calendar');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('card');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('carousel');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('checkbox');

View File

@ -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();
});
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('collapse');

View File

@ -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();
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('dropdown');

View File

@ -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);
});
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('form');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('grid');

View File

@ -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');
});
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('input-number');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('input');

View File

@ -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');
});
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('locale-provider');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('mention', { skip: true });

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('menu');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('message');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('modal');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('notification');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('pagination');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('popconfirm');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('popover');

View File

@ -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>/);
});
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('progress');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('radio');

View File

@ -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();
});
});

View File

@ -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();
});
});

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('rate');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('select');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('slider');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('spin');

View File

@ -1,3 +0,0 @@
import demoTest from '../shared/demoTest';
demoTest('steps');

View File

@ -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