mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-18 06:03:38 +08:00
Revert "use ava and enzyme, replace jest" (#2144)
This commit is contained in:
parent
3cf0a59916
commit
193fa8e9d6
42
package.json
42
package.json
@ -74,8 +74,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"antd-tools": "^0.8.0",
|
||||
"ava": "^0.15.2",
|
||||
"babel-eslint": "^6.0.2",
|
||||
"babel-jest": "^12.0.2",
|
||||
"babel-plugin-antd": "^0.4.0",
|
||||
"bisheng": "^0.7.1",
|
||||
"bisheng-plugin-antd": "0.1.0",
|
||||
@ -84,7 +84,7 @@
|
||||
"bisheng-plugin-toc": "0.2.0",
|
||||
"dora-plugin-upload": "^0.3.1",
|
||||
"enquire.js": "^2.1.1",
|
||||
"enzyme": "^2.3.0",
|
||||
"es6-shim": "^0.35.0",
|
||||
"eslint": "^2.2.0",
|
||||
"eslint-config-airbnb": "^9.0.1",
|
||||
"eslint-plugin-babel": "^3.0.0",
|
||||
@ -96,6 +96,7 @@
|
||||
"history": "^2.0.1",
|
||||
"intl": "^1.2.2",
|
||||
"intl-locales-supported": "^1.0.0",
|
||||
"jest-cli": "^12.0.2",
|
||||
"jsonml-to-react-component": "~0.2.0",
|
||||
"jsonml.js": "^0.1.0",
|
||||
"jsonp": "^0.2.0",
|
||||
@ -115,9 +116,11 @@
|
||||
"react-github-button": "^0.1.1",
|
||||
"react-intl": "^2.0.1",
|
||||
"react-router": "^2.0.0",
|
||||
"react-stateless-wrapper": "^1.0.2",
|
||||
"react-sublime-video": "^0.2.0",
|
||||
"reqwest": "^2.0.5",
|
||||
"values.js": "^1.0.3"
|
||||
"values.js": "^1.0.3",
|
||||
"webpack-babel-jest": "^1.0.4"
|
||||
},
|
||||
"scripts": {
|
||||
"dist": "antd-tools run dist",
|
||||
@ -133,25 +136,30 @@
|
||||
"demolint": "RUN_ENV=DEMO eslint components/*/demo/*.md --ext '.md'",
|
||||
"lesshint": "lesshint components -r scripts/lesshint-report.js",
|
||||
"eslint-fix": "eslint --fix components test site scripts ./*.js --ext '.js,.jsx' && eslint-tinker ./components/*/demo/*.md",
|
||||
"test": "npm run lint && npm run dist && npm run ava",
|
||||
"ava": "ava tests/*.test.js",
|
||||
"test": "npm run lint && npm run dist && npm run jest",
|
||||
"jest": "jest",
|
||||
"pre-publish": "node ./scripts/prepub",
|
||||
"prepublish": "antd-tools run guard",
|
||||
"pub": "antd-tools run update-self && antd-tools run pub",
|
||||
"authors": "git log --format='%aN <%aE>' | sort -u | grep -v 'users.noreply.github.com' | grep -v 'gitter.im' | grep -v '.local>' | grep -v 'alibaba-inc.com' | grep -v 'alipay.com' | grep -v 'taobao.com' > AUTHORS.txt"
|
||||
},
|
||||
"ava": {
|
||||
"babel": {
|
||||
"presets": [
|
||||
"es2015",
|
||||
"stage-0",
|
||||
"react"
|
||||
]
|
||||
},
|
||||
"require": [
|
||||
"./tests/helpers/setup-browser-env.js",
|
||||
"babel-register"
|
||||
]
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"jsx",
|
||||
"json"
|
||||
],
|
||||
"unmockedModulePathPatterns": [
|
||||
"<rootDir>/node_modules/*"
|
||||
],
|
||||
"modulePathIgnorePatterns": [
|
||||
"/_site/"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"/node_modules/"
|
||||
],
|
||||
"scriptPreprocessor": "<rootDir>/node_modules/webpack-babel-jest",
|
||||
"testDirectoryName": "tests"
|
||||
},
|
||||
"pre-commit": [
|
||||
"lint"
|
||||
|
@ -1,23 +1,34 @@
|
||||
import test from 'ava';
|
||||
jest.unmock('../components/button/button');
|
||||
jest.unmock('../components/icon/index');
|
||||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import TestUtils from 'react-addons-test-utils';
|
||||
import Button from '../components/button/button';
|
||||
|
||||
let buttonNode;
|
||||
describe('Button', function() {
|
||||
let button;
|
||||
let buttonNode;
|
||||
|
||||
test.beforeEach(() => {
|
||||
buttonNode = shallow(<Button>Follow</Button>);
|
||||
});
|
||||
beforeEach(() => {
|
||||
button = TestUtils.renderIntoDocument(
|
||||
<Button>Follow</Button>
|
||||
);
|
||||
buttonNode = TestUtils.findRenderedDOMComponentWithTag(button, 'button');
|
||||
});
|
||||
|
||||
test('should set the type to button by default', (t) => {
|
||||
t.is(buttonNode.type(), 'button');
|
||||
});
|
||||
it('should set the type to button by default', () => {
|
||||
expect(buttonNode.type).toBe('button');
|
||||
});
|
||||
|
||||
test('should set the default className to button', (t) => {
|
||||
t.true(buttonNode.hasClass('ant-btn'));
|
||||
});
|
||||
it('should set the default className to button', () => {
|
||||
expect(buttonNode.className).toBe('ant-btn');
|
||||
});
|
||||
|
||||
test('should has a whitespace in two Chinese charactor', (t) => {
|
||||
buttonNode = shallow(<Button>按钮</Button>);
|
||||
t.is(buttonNode.text(), '按 钮');
|
||||
it('should has a whitespace in two Chinese charactor', () => {
|
||||
button = TestUtils.renderIntoDocument(
|
||||
<Button>按钮</Button>
|
||||
);
|
||||
buttonNode = TestUtils.findRenderedDOMComponentWithTag(button, 'button');
|
||||
expect(buttonNode.textContent).toBe('按 钮');
|
||||
});
|
||||
});
|
||||
|
@ -1,3 +0,0 @@
|
||||
global.document = require('jsdom').jsdom('<body></body>');
|
||||
global.window = document.defaultView;
|
||||
global.navigator = window.navigator;
|
@ -1,19 +1,27 @@
|
||||
import test from 'ava';
|
||||
jest.unmock('../components/icon/index');
|
||||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import Icon from '../components/icon/index';
|
||||
import TestUtils from 'react-addons-test-utils';
|
||||
import { wrap } from 'react-stateless-wrapper';
|
||||
|
||||
let iconNode;
|
||||
import AntIcon from '../components/icon/index';
|
||||
const Icon = wrap(AntIcon);
|
||||
|
||||
test.beforeEach(() => {
|
||||
iconNode = shallow(
|
||||
<Icon type="appstore" className="my-icon-classname" />
|
||||
);
|
||||
});
|
||||
|
||||
test('should render to a <i class="xxx"></i>', (t) => {
|
||||
t.is(iconNode.type(), 'i');
|
||||
t.true(iconNode.hasClass('my-icon-classname'));
|
||||
t.true(iconNode.hasClass('anticon'));
|
||||
t.true(iconNode.hasClass('anticon-appstore'));
|
||||
describe('Icon', function() {
|
||||
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');
|
||||
});
|
||||
});
|
||||
|
@ -2,13 +2,13 @@
|
||||
import React from 'react';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import test from 'ava';
|
||||
|
||||
(function() {
|
||||
const distFilesExisted = fs.existsSync(path.join(process.cwd(), '..', 'dist', 'antd.js'));
|
||||
describe('antd dist files', function() {
|
||||
const distFilesExisted = fs.existsSync(path.join(process.cwd(), 'dist', 'antd.js'));
|
||||
if (!distFilesExisted) {
|
||||
test(t => t.pass());
|
||||
return;
|
||||
} else {
|
||||
jest.unmock('../dist/antd');
|
||||
}
|
||||
|
||||
// fixed jsdom miss
|
||||
@ -29,64 +29,63 @@ import test from 'ava';
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/1638
|
||||
// https://github.com/ant-design/ant-design/issues/1968
|
||||
test('should has modules in antd', (t) => {
|
||||
t.true('Affix' in antd);
|
||||
t.true('Alert' in antd);
|
||||
t.true('Badge' in antd);
|
||||
t.true('Breadcrumb' in antd);
|
||||
t.true('Button' in antd);
|
||||
t.true('Calendar' in antd);
|
||||
t.true('Card' in antd);
|
||||
t.true('Carousel' in antd);
|
||||
t.true('Cascader' in antd);
|
||||
t.true('Checkbox' in antd);
|
||||
t.true('Col' in antd);
|
||||
t.true('Collapse' in antd);
|
||||
t.true('DatePicker' in antd);
|
||||
t.true('Dropdown' in antd);
|
||||
t.true('Form' in antd);
|
||||
t.true('Icon' in antd);
|
||||
t.true('Input' in antd);
|
||||
t.true('InputNumber' in antd);
|
||||
t.true('LocaleProvider' in antd);
|
||||
t.true('Menu' in antd);
|
||||
t.true('message' in antd);
|
||||
t.true('Modal' in antd);
|
||||
t.true('notification' in antd);
|
||||
t.true('Pagination' in antd);
|
||||
t.true('Popconfirm' in antd);
|
||||
t.true('Popover' in antd);
|
||||
t.true('Progress' in antd);
|
||||
t.true('QueueAnim' in antd);
|
||||
t.true('Radio' in antd);
|
||||
t.true('Rate' in antd);
|
||||
t.true('Row' in antd);
|
||||
t.true('Select' in antd);
|
||||
t.true('Slider' in antd);
|
||||
t.true('Spin' in antd);
|
||||
t.true('Steps' in antd);
|
||||
t.true('Switch' in antd);
|
||||
t.true('Table' in antd);
|
||||
t.true('Tabs' in antd);
|
||||
t.true('Tag' in antd);
|
||||
t.true('TimePicker' in antd);
|
||||
t.true('Timeline' in antd);
|
||||
t.true('Tooltip' in antd);
|
||||
t.true('Transfer' in antd);
|
||||
t.true('Tree' in antd);
|
||||
t.true('TreeSelect' in antd);
|
||||
t.true('Upload' in antd);
|
||||
t.true('Validation' in antd);
|
||||
it('should has modules in antd', () => {
|
||||
expect('Affix' in antd).toBeTruthy();
|
||||
expect('Alert' in antd).toBeTruthy();
|
||||
expect('Badge' in antd).toBeTruthy();
|
||||
expect('Breadcrumb' in antd).toBeTruthy();
|
||||
expect('Button' in antd).toBeTruthy();
|
||||
expect('Calendar' in antd).toBeTruthy();
|
||||
expect('Card' in antd).toBeTruthy();
|
||||
expect('Carousel' in antd).toBeTruthy();
|
||||
expect('Cascader' in antd).toBeTruthy();
|
||||
expect('Checkbox' in antd).toBeTruthy();
|
||||
expect('Col' in antd).toBeTruthy();
|
||||
expect('Collapse' in antd).toBeTruthy();
|
||||
expect('DatePicker' in antd).toBeTruthy();
|
||||
expect('Dropdown' in antd).toBeTruthy();
|
||||
expect('Form' in antd).toBeTruthy();
|
||||
expect('Icon' in antd).toBeTruthy();
|
||||
expect('Input' in antd).toBeTruthy();
|
||||
expect('InputNumber' in antd).toBeTruthy();
|
||||
expect('LocaleProvider' in antd).toBeTruthy();
|
||||
expect('Menu' in antd).toBeTruthy();
|
||||
expect('message' in antd).toBeTruthy();
|
||||
expect('Modal' in antd).toBeTruthy();
|
||||
expect('notification' in antd).toBeTruthy();
|
||||
expect('Pagination' in antd).toBeTruthy();
|
||||
expect('Popconfirm' in antd).toBeTruthy();
|
||||
expect('Popover' in antd).toBeTruthy();
|
||||
expect('Progress' in antd).toBeTruthy();
|
||||
expect('QueueAnim' in antd).toBeTruthy();
|
||||
expect('Radio' in antd).toBeTruthy();
|
||||
expect('Rate' in antd).toBeTruthy();
|
||||
expect('Row' in antd).toBeTruthy();
|
||||
expect('Select' in antd).toBeTruthy();
|
||||
expect('Slider' in antd).toBeTruthy();
|
||||
expect('Spin' in antd).toBeTruthy();
|
||||
expect('Steps' in antd).toBeTruthy();
|
||||
expect('Switch' in antd).toBeTruthy();
|
||||
expect('Table' in antd).toBeTruthy();
|
||||
expect('Tabs' in antd).toBeTruthy();
|
||||
expect('Tag' in antd).toBeTruthy();
|
||||
expect('TimePicker' in antd).toBeTruthy();
|
||||
expect('Timeline' in antd).toBeTruthy();
|
||||
expect('Tooltip' in antd).toBeTruthy();
|
||||
expect('Transfer' in antd).toBeTruthy();
|
||||
expect('Tree' in antd).toBeTruthy();
|
||||
expect('TreeSelect' in antd).toBeTruthy();
|
||||
expect('Upload' in antd).toBeTruthy();
|
||||
expect('Validation' in antd).toBeTruthy();
|
||||
});
|
||||
|
||||
// https://github.com/ant-design/ant-design/issues/1970
|
||||
// https://github.com/ant-design/ant-design/issues/1804
|
||||
test('should be compatible in IE8', (t) => {
|
||||
const antdJsContent = fs.readFileSync(path.join(process.cwd(), '..', 'dist', 'antd.js'));
|
||||
t.is(
|
||||
it('should be compatible in IE8', () => {
|
||||
const antdJsContent = fs.readFileSync(path.join(process.cwd(), 'dist', 'antd.js'));
|
||||
expect(
|
||||
antdJsContent.toString()
|
||||
.indexOf('function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }'),
|
||||
-1
|
||||
);
|
||||
.indexOf('function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }')
|
||||
).toBe(-1);
|
||||
})
|
||||
})();
|
||||
});
|
||||
|
@ -1,14 +1,27 @@
|
||||
import test from 'ava';
|
||||
jest.unmock('../components/layout/index');
|
||||
jest.unmock('../components/layout/col');
|
||||
jest.unmock('../components/layout/row');
|
||||
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { Col, Row } from '../components/layout/index';
|
||||
import TestUtils from 'react-addons-test-utils';
|
||||
import { wrap } from 'react-stateless-wrapper';
|
||||
|
||||
test('should render Col', (t) => {
|
||||
const col = shallow(<Col span={2} />);
|
||||
t.true(col.hasClass('ant-col-2'));
|
||||
});
|
||||
let { Col, Row } = require('../components/layout/index');
|
||||
Col = wrap(Col);
|
||||
|
||||
test('should render Row', (t) => {
|
||||
const row = shallow(<Row />);
|
||||
t.true(row.hasClass('ant-row'));
|
||||
describe('Layout', function() {
|
||||
it('should render Col', () => {
|
||||
const col = TestUtils.renderIntoDocument(
|
||||
<Col span="2"></Col>
|
||||
);
|
||||
const colNode = TestUtils.findRenderedDOMComponentWithTag(col, 'DIV');
|
||||
expect(colNode.className).toBe('ant-col-2');
|
||||
});
|
||||
it('should render Row', () => {
|
||||
const row = TestUtils.renderIntoDocument(
|
||||
<Row></Row>
|
||||
);
|
||||
const rowNode = TestUtils.findRenderedDOMComponentWithTag(row, 'DIV');
|
||||
expect(rowNode.className).toBe('ant-row');
|
||||
});
|
||||
});
|
||||
|
@ -1,21 +1,29 @@
|
||||
import test from 'ava';
|
||||
jest.unmock('../components/popover/placements');
|
||||
jest.unmock('../components/popover/index');
|
||||
jest.unmock('../components/tooltip/index');
|
||||
|
||||
import React from 'react';
|
||||
import Popover from '../components/popover'
|
||||
import { mount } from 'enzyme';
|
||||
import TestUtils from 'react-addons-test-utils';
|
||||
import Popover from '../components/popover/index';
|
||||
|
||||
test('should show overlay when trigger is clicked', (t) => {
|
||||
const popover = mount(
|
||||
<Popover content="console.log('hello world')" title="code" trigger="click">
|
||||
<a href="#">show me your code</a>
|
||||
</Popover>
|
||||
);
|
||||
describe('Popover', function() {
|
||||
it('should show overlay when trigger is clicked', () => {
|
||||
const popover = TestUtils.renderIntoDocument(
|
||||
<Popover content="console.log('hello world')" title="code" trigger="click">
|
||||
<a href="#">show me your code</a>
|
||||
</Popover>
|
||||
);
|
||||
|
||||
t.is(popover.instance().getPopupDomNode(), undefined);
|
||||
expect(popover.getPopupDomNode()).toBe(undefined);
|
||||
|
||||
popover.find('a').simulate('click');
|
||||
TestUtils.Simulate.click(
|
||||
TestUtils.findRenderedDOMComponentWithTag(popover, 'a')
|
||||
);
|
||||
|
||||
const popup = popover.instance().getPopupDomNode();
|
||||
t.truthy(popup);
|
||||
t.true(popup.className.indexOf('ant-popover-placement-top') > 0);
|
||||
t.is(popup.innerHTML, '<div class="ant-popover-content"><div class="ant-popover-arrow"></div><div class="ant-popover-inner">code</div></div>');
|
||||
const popup = popover.getPopupDomNode();
|
||||
expect(popup).not.toBe(undefined);
|
||||
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>/);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user