cleanup npm scripts (#4499)

* Cleanup npm scripts

* Lint fix

* Don't need ignore js files

* Upgrade jest

* Add components index.tsx test
This commit is contained in:
Wei Zhu 2017-01-08 17:04:09 +08:00 committed by 偏右
parent 6495ef3592
commit f6c0e69af5
11 changed files with 107 additions and 104 deletions

3
.gitignore vendored
View File

@ -27,9 +27,6 @@ dist
/lib
elasticsearch-*
config/base.yaml
components/**/*.js
components/**/*.jsx
/.vscode/
/coverage
!components/**/__tests__/*
yarn.lock

View File

@ -1,6 +1,6 @@
{
"setupFiles": [
"tests/setup.js"
"./tests/setup.js"
],
"moduleFileExtensions": [
"ts",
@ -9,9 +9,9 @@
"md"
],
"transform": {
"\\.tsx?$": "node_modules/typescript-babel-jest",
"\\.js$": "node_modules/babel-jest",
"\\.md$": "node_modules/antd-demo-jest"
"\\.tsx?$": "./node_modules/typescript-babel-jest",
"\\.js$": "./node_modules/babel-jest",
"\\.md$": "./node_modules/antd-demo-jest"
},
"testRegex": "demo\\.test\\.js$",
"testEnvironment": "node"

View File

@ -5,5 +5,11 @@ language: node_js
node_js:
- "6"
env:
- MAX_WORKERS=2
script:
- npm run test-all
after_script:
- cat ./coverage/lcov.info | node_modules/coveralls/bin/coveralls.js

View File

@ -0,0 +1,54 @@
exports[`antd exports modules correctly 1`] = `
Array [
"Affix",
"Anchor",
"AutoComplete",
"Alert",
"BackTop",
"Badge",
"Breadcrumb",
"Button",
"Calendar",
"Card",
"Collapse",
"Carousel",
"Cascader",
"Checkbox",
"Col",
"DatePicker",
"Dropdown",
"Form",
"Icon",
"Input",
"InputNumber",
"Layout",
"LocaleProvider",
"message",
"Menu",
"Modal",
"notification",
"Pagination",
"Popconfirm",
"Popover",
"Progress",
"Radio",
"Rate",
"Row",
"Select",
"Slider",
"Spin",
"Steps",
"Switch",
"Table",
"Transfer",
"Tree",
"TreeSelect",
"Tabs",
"Tag",
"TimePicker",
"Timeline",
"Tooltip",
"Mention",
"Upload",
]
`;

View File

@ -0,0 +1,7 @@
import * as antd from '..';
describe('antd', () => {
it('exports modules correctly', () => {
expect(Object.keys(antd)).toMatchSnapshot();
});
});

View File

@ -41,7 +41,7 @@ describe('Radio', () => {
const wrapper = mount(
createRadioGroup({
onChange
onChange,
})
);
const radios = wrapper.find('input');
@ -62,7 +62,7 @@ describe('Radio', () => {
const wrapper = mount(
createRadioGroup({
onChange
onChange,
})
);
const radios = wrapper.find('input');

View File

@ -166,12 +166,8 @@ describe('Table.rowSelection', () => {
// https://github.com/ant-design/ant-design/issues/4245
it('handles disabled checkbox correctly when dataSource changes', () => {
const data = [
{ key: 0, name: 'Jack', disabled: false },
{ key: 1, name: 'Lucy', disabled: false },
];
const rowSelection = {
getCheckboxProps: (record) => ({ disabled: record.disabled }),
getCheckboxProps: record => ({ disabled: record.disabled }),
};
const wrapper = mount(createTable({ rowSelection }));
const newData = [
@ -179,7 +175,7 @@ describe('Table.rowSelection', () => {
{ key: 1, name: 'Lucy', disabled: true },
];
wrapper.setProps({ dataSource: newData });
wrapper.find('input').forEach(checkbox => {
wrapper.find('input').forEach((checkbox) => {
expect(checkbox.props().disabled).toBe(true);
});
});

View File

@ -106,13 +106,12 @@
"eslint-plugin-markdown": "1.0.0-beta.3",
"eslint-plugin-react": "^6.1.2",
"eslint-tinker": "^0.4.0",
"fetch-jsonp": "^1.0.3",
"glob": "^7.1.1",
"history": "^4.4.0",
"jest": "^17.0.1",
"jest-cli": "^17.0.0",
"jest": "^18.1.0",
"jsonml-to-react-component": "~0.2.0",
"jsonml.js": "^0.1.0",
"fetch-jsonp": "^1.0.3",
"lesshint": "^2.0.0",
"lodash.debounce": "^4.0.6",
"mockdate": "^2.0.1",
@ -138,20 +137,18 @@
"xhr2": "^0.1.3"
},
"scripts": {
"test": "npm run lint && npm run dist && npm run jest -- --coverage -w 2 && npm run jest:node -- -w 2",
"test": "jest",
"test-all": "./scripts/test-all.sh",
"lint": "npm run tslint && npm run eslint && npm run demolint && npm run lesshint",
"tslint": "antd-tools run ts-lint && npm run compile && rm -rf lib",
"eslint": "eslint tests site scripts ./.eslintrc.js ./webpack.config.js --ext '.js,.jsx,.tsx' --ignore-pattern '!.eslintrc.js'",
"eslint": "eslint tests site scripts components ./.eslintrc.js ./webpack.config.js --ext '.js,.jsx' --ignore-pattern '!.eslintrc.js'",
"demolint": "RUN_ENV=DEMO eslint components/*/demo/*.md --ext '.md'",
"lesshint": "lesshint components -r scripts/lesshint-report.js",
"eslint-fix": "eslint --fix tests site scripts ./.eslintrc.js ./webpack.config.js --ext '.js,.jsx,.tsx' --ignore-pattern '!.eslintrc.js' && eslint-tinker ./components/*/demo/*.md",
"jest": "jest",
"jest:node": "jest --config .jest.node.json",
"eslint-fix": "eslint --fix tests site scripts components ./.eslintrc.js ./webpack.config.js --ext '.js,.jsx' --ignore-pattern '!.eslintrc.js' && eslint-tinker ./components/*/demo/*.md",
"clean": "antd-tools run clean",
"dist": "antd-tools run dist && node ./tests/dekko/dist.test.js",
"compile": "antd-tools run compile && node ./tests/dekko/lib.test.js",
"dist": "antd-tools run dist",
"compile": "antd-tools run compile",
"start": "bisheng start -c ./site/bisheng.config.js --no-livereload",
"babel-site": "babel ./site/theme/template --out-dir ./site/theme/template",
@ -161,12 +158,12 @@
"pub": "antd-tools run update-self && antd-tools run pub",
"prepublish": "antd-tools run guard",
"pre-publish": "node ./scripts/prepub",
"pre-publish": "npm run test-all && node ./scripts/prepub",
"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"
},
"jest": {
"setupFiles": [
"tests/setup.js"
"./tests/setup.js"
],
"moduleFileExtensions": [
"ts",
@ -185,9 +182,9 @@
"node"
],
"transform": {
"\\.tsx?$": "node_modules/typescript-babel-jest",
"\\.js$": "node_modules/babel-jest",
"\\.md$": "node_modules/antd-demo-jest"
"\\.tsx?$": "./node_modules/typescript-babel-jest",
"\\.js$": "./node_modules/babel-jest",
"\\.md$": "./node_modules/antd-demo-jest"
},
"testRegex": ".*\\.test\\.js$",
"collectCoverageFrom": [

9
scripts/test-all.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
npm run lint && \
npm run dist && \
node ./tests/dekko/dist.test.js && \
npm run compile && \
node ./tests/dekko/lib.test.js && \
npm test -- --coverage -w $MAX_WORKERS && \
npm test -- --config .jest.node.json -w $MAX_WORKERS

View File

@ -52,58 +52,3 @@ Array [
"Upload",
]
`;
exports[`antd dist files exports modules correctly 2`] = `
Array [
"Affix",
"Anchor",
"AutoComplete",
"Alert",
"BackTop",
"Badge",
"Breadcrumb",
"Button",
"Calendar",
"Card",
"Collapse",
"Carousel",
"Cascader",
"Checkbox",
"Col",
"DatePicker",
"Dropdown",
"Form",
"Icon",
"Input",
"InputNumber",
"Layout",
"LocaleProvider",
"message",
"Menu",
"Modal",
"notification",
"Pagination",
"Popconfirm",
"Popover",
"Progress",
"Radio",
"Rate",
"Row",
"Select",
"Slider",
"Spin",
"Steps",
"Switch",
"Table",
"Transfer",
"Tree",
"TreeSelect",
"Tabs",
"Tag",
"TimePicker",
"Timeline",
"Tooltip",
"Mention",
"Upload",
]
`;

View File

@ -1,31 +1,23 @@
// Test dist files
import fs from 'fs';
import path from 'path';
describe('antd dist files', () => {
const distFilesExisted = fs.existsSync(path.join(process.cwd(), 'dist', 'antd.js'));
if (!distFilesExisted) {
it('empty test case placeholder', () => {});
return;
}
const antd = require('../dist/antd'); // eslint-disable-line global-require
const antdInComponents = require('../components/'); // eslint-disable-line global-require
// https://github.com/ant-design/ant-design/issues/1638
// https://github.com/ant-design/ant-design/issues/1968
it('exports modules correctly', () => {
const antd = process.env.CI ? require('../dist/antd') : require('../components'); // eslint-disable-line global-require
expect(Object.keys(antd)).toMatchSnapshot();
expect(Object.keys(antdInComponents)).toMatchSnapshot();
});
// https://github.com/ant-design/ant-design/issues/1970
// https://github.com/ant-design/ant-design/issues/1804
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 }; }')
).toBe(-1);
});
if (process.env.CI) {
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 }; }')
).toBe(-1);
});
}
});