Skip to content

Commit

Permalink
Revert "setup(jest+typescript): 修改jest配置,使测试支持typescript"
Browse files Browse the repository at this point in the history
This reverts commit d87c4c3.
  • Loading branch information
eynol committed Jul 26, 2018
1 parent e5fa7dc commit 297f53d
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 57 deletions.
8 changes: 1 addition & 7 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,7 @@
]
},
"test": {
"plugins":["dynamic-import-node"],
"presets": [
"env",
"stage-1",
"stage-2",
"react"
]
"presets": ["react-app"]
}
}
}
32 changes: 6 additions & 26 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,12 @@ module.exports = {
setupFiles: [
'<rootDir>/source/tests/setup.js',
],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tools/assetsTransformer.js",
"\\.(css|less)$": "<rootDir>/tools/assetsTransformer.js"
},
moduleFileExtensions: [
"ts", "tsx", "js"
],
transform: {
"^.+\\.js$": "babel-jest",
"^.+\\.tsx?$": "ts-jest"
},
globals: {
"ts-jest": {
"tsConfigFile": "tsconfig.json",
"enableTsDiagnostics": true,

},
"NODE_ENV": "test"
},
testMatch: [
"**/__tests__/**/*.(ts|tsx|js)",
"**/?(*.)+(test).(ts|tsx|js)"
],
testPathIgnorePatterns: [
"<rootDir>/node_modules/",
],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tools/assetsTransformer.js",
"\\.(css|less)$": "<rootDir>/tools/assetsTransformer.js"
},
moduleFileExtensions: ["js"],
testMatch: [ "**/__tests__/**/*.js", "**/?(*.)+(test).js" ],
verbose: true,
notify: false,
collectCoverage: false,
Expand Down
4 changes: 0 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@
"react-dom": ">= 16.1.1"
},
"devDependencies": {
"@types/enzyme": "^3.1.12",
"@types/jest": "^23.3.0",
"@types/node": "^10.5.2",
"@types/react": "^16.4.6",
"@types/react-dom": "^16.0.6",
Expand All @@ -76,7 +74,6 @@
"babel-jest": "^23.0.1",
"babel-loader": "^7.1.2",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-dynamic-import-node": "^2.0.0",
"babel-plugin-import": "^1.4.0",
"babel-plugin-react-display-name": "^2.0.0",
"babel-preset-env": "^1.6.1",
Expand Down Expand Up @@ -147,7 +144,6 @@
"style-loader": "^0.18.1",
"stylelint": "^8.3.1",
"stylelint-config-standard": "^18.0.0",
"ts-jest": "^23.0.1",
"typescript": "^2.9.2",
"url-loader": "^0.5.8",
"uuid": "^3.1.0",
Expand Down
3 changes: 0 additions & 3 deletions source/components/Button/__tests__/demo.test.js

This file was deleted.

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

demoTest('button');
25 changes: 9 additions & 16 deletions ...components/Button/__tests__/index.test.js → ...onents/Button/__tests__/index.test.js.bak
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import React, { Component } from 'react';
import { render, mount } from 'enzyme';
import Button from '../index';
import Icon from '../../Icon/index';
import * as TestUtils from 'react-dom/test-utils';
import Button from '..';
import Icon from '../../Icon';

describe('Button', () => {
it('renders correctly', () => {
Expand Down Expand Up @@ -49,22 +48,17 @@ describe('Button', () => {
const wrapper = mount(
<Button><Text>按钮</Text></Button>
);


const defaultPrefix = Button.defaultProps.prefixCls;
const prefixCls = '.' + defaultPrefix;

expect(wrapper.find(prefixCls).hasClass(`${defaultPrefix}-two-chinese-chars`)).toBe(true);
expect(wrapper.find('.ant-btn').hasClass('ant-btn-two-chinese-chars')).toBe(true);
wrapper.setProps({
children: <Text>大按钮</Text>,
});
wrapper.update();
expect(wrapper.find(prefixCls).hasClass(`${defaultPrefix}-two-chinese-chars`)).toBe(false);
expect(wrapper.find('.ant-btn').hasClass('ant-btn-two-chinese-chars')).toBe(false);
wrapper.setProps({
children: <Text>按钮</Text>,
});
wrapper.update();
expect(wrapper.find(prefixCls).hasClass(`${defaultPrefix}-two-chinese-chars`)).toBe(true);
expect(wrapper.find('.ant-btn').hasClass('ant-btn-two-chinese-chars')).toBe(true);
});

it('have static property for type detecting', () => {
Expand All @@ -76,7 +70,7 @@ describe('Button', () => {
});

it('should change loading state instantly by default', () => {
class DefaultButton extends React.Component {
class DefaultButton extends Component {
state = {
loading: false,
};
Expand All @@ -93,14 +87,13 @@ describe('Button', () => {
const wrapper = mount(
<DefaultButton />
);
const defaultPrefix = Button.defaultProps.prefixCls;
wrapper.simulate('click');
expect(wrapper.find(`.${defaultPrefix}-loading`).length).toBe(1);
expect(wrapper.find('.ant-btn-loading').length).toBe(1);
});

it('should change loading state with delay', () => {
// eslint-disable-next-line
class DefaultButton extends React.Component {
class DefaultButton extends Component {
state = {
loading: false,
};
Expand Down
2 changes: 1 addition & 1 deletion source/tests/polyfills/getSelection.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ function getSelectionShim() {
setEnd: function() {},
addRange: function() {},
};
}
};

0 comments on commit 297f53d

Please sign in to comment.