Skip to content

Commit

Permalink
Don't ignore test files.
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Dec 14, 2016
1 parent 17a0a33 commit 07103b9
Show file tree
Hide file tree
Showing 64 changed files with 995 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ components/**/*.js
components/**/*.jsx
/.vscode/
/coverage
!components/**/__tests__/*
3 changes: 3 additions & 0 deletions components/affix/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('affix');
3 changes: 3 additions & 0 deletions components/alert/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('alert');
20 changes: 20 additions & 0 deletions components/anchor/__tests__/Anchor.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { mount } from 'enzyme';
import Anchor from '..';

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);
});
});
3 changes: 3 additions & 0 deletions components/anchor/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('anchor');
3 changes: 3 additions & 0 deletions components/auto-complete/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('auto-complete');
3 changes: 3 additions & 0 deletions components/back-top/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('back-top');
3 changes: 3 additions & 0 deletions components/badge/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('badge');
12 changes: 12 additions & 0 deletions components/breadcrumb/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { render } from 'enzyme';
import { renderToJson } from 'enzyme-to-json';
import demoTest from '../../../tests/shared/demoTest';
import routerDemo from '../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();
});
3 changes: 3 additions & 0 deletions components/calendar/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('calendar');
3 changes: 3 additions & 0 deletions components/card/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('card');
3 changes: 3 additions & 0 deletions components/carousel/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('carousel');
3 changes: 3 additions & 0 deletions components/cascader/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('cascader');
3 changes: 3 additions & 0 deletions components/checkbox/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('checkbox');
23 changes: 23 additions & 0 deletions components/checkbox/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { shallow } from 'enzyme';
import Checkbox from '..';

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();
});
});
3 changes: 3 additions & 0 deletions components/collapse/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('collapse');
Binary file not shown.
14 changes: 14 additions & 0 deletions components/date-picker/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { render } from 'enzyme';
import { renderToJson } from 'enzyme-to-json';
import MockDate from 'mockdate';
import demoTest from '../../../tests/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('../demo/locale'); // eslint-disable-line global-require
const wrapper = render(LocaleDemo);
expect(renderToJson(wrapper)).toMatchSnapshot();
MockDate.reset();
});
3 changes: 3 additions & 0 deletions components/dropdown/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('dropdown');
36 changes: 36 additions & 0 deletions components/dropdown/__tests__/dropdown-button.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { shallow } from 'enzyme';
import Dropdown from '..';
import Menu from '../../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);
});
});
3 changes: 3 additions & 0 deletions components/form/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('form');
3 changes: 3 additions & 0 deletions components/grid/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('grid');
20 changes: 20 additions & 0 deletions components/grid/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { Col, Row } from '..';

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');
});
});
25 changes: 25 additions & 0 deletions components/icon/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import { wrap } from 'react-stateless-wrapper';
import AntIcon from '..';

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');
});
});
3 changes: 3 additions & 0 deletions components/input-number/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('input-number');
3 changes: 3 additions & 0 deletions components/input/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('input');
3 changes: 3 additions & 0 deletions components/locale-provider/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('locale-provider');
3 changes: 3 additions & 0 deletions components/mention/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('mention', { skip: true });
3 changes: 3 additions & 0 deletions components/menu/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('menu');
3 changes: 3 additions & 0 deletions components/message/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('message');
3 changes: 3 additions & 0 deletions components/modal/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('modal');
3 changes: 3 additions & 0 deletions components/notification/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('notification');
3 changes: 3 additions & 0 deletions components/pagination/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('pagination');
3 changes: 3 additions & 0 deletions components/popconfirm/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('popconfirm');
3 changes: 3 additions & 0 deletions components/popover/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('popover');
25 changes: 25 additions & 0 deletions components/popover/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import Popover from '..';

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>/);
});
});
3 changes: 3 additions & 0 deletions components/progress/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('progress');
3 changes: 3 additions & 0 deletions components/radio/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('radio');
26 changes: 26 additions & 0 deletions components/radio/__tests__/group.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { shallow } from 'enzyme';
import Radio from '../radio';
import RadioGroup from '../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();
});
});
23 changes: 23 additions & 0 deletions components/radio/__tests__/radio.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { shallow } from 'enzyme';
import Radio from '../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();
});
});
3 changes: 3 additions & 0 deletions components/rate/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('rate');
3 changes: 3 additions & 0 deletions components/select/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('select');
3 changes: 3 additions & 0 deletions components/slider/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('slider');
3 changes: 3 additions & 0 deletions components/spin/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('spin');
3 changes: 3 additions & 0 deletions components/steps/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('steps');
3 changes: 3 additions & 0 deletions components/switch/__tests__/demo.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import demoTest from '../../../tests/shared/demoTest';

demoTest('switch');
Loading

0 comments on commit 07103b9

Please sign in to comment.