Skip to content

Commit

Permalink
refactor: upgrade react to 15.x
Browse files Browse the repository at this point in the history
  • Loading branch information
ex90rts committed Oct 17, 2017
1 parent cb1630d commit dcc4d1b
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
*.iml
*.log
.happypack/
.idea/
.ipr
.iws
Expand All @@ -27,5 +26,6 @@ spm_modules
.happypack
dist
build
coverage
package-lock.json
assets/**/*.css
coverage/*
15 changes: 12 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@ language: node_js

sudo: false

addons:
apt:
packages:
- xvfb

notification:
email:
- wsj7552715@hotmail.com

node_js:
- 4.0.0
- 6.9.0

before_install:
- |
Expand All @@ -17,6 +22,11 @@ before_install:
exit
fi
phantomjs --version
install:
- export DISPLAY=':99.0'
- Xvfb :99 -screen 0 1024x768x24 > /dev/null 2>&1 &
- npm install


script:
- |
Expand All @@ -25,7 +35,6 @@ script:
else
npm run $TEST_TYPE
fi
env:
matrix:
- TEST_TYPE=test
Expand All @@ -34,4 +43,4 @@ env:

matrix:
allow_failures:
- env: "TEST_TYPE=saucelabs"
- env: "TEST_TYPE=saucelabs"
111 changes: 54 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,58 +1,55 @@
{
"name": "uxcore-steps",
"version": "2.1.3",
"description": "uxcore-steps component for uxcore.",
"repository": "https://github.com/uxcore/uxcore-steps.git",
"author": "vincent.bian",
"main": "build/index.js",
"scripts": {
"start": "uxcore-tools run start",
"server": "uxcore-tools run server",
"lint": "uxcore-tools run lint",
"build": "uxcore-tools run build",
"test": "uxcore-tools run test",
"coverage": "uxcore-tools run coverage",
"pub": "uxcore-tools run pub",
"dep": "uxcore-tools run dep",
"tnpm-dep": "uxcore-tools run tnpm-dep",
"chrome": "uxcore-tools run chrome",
"browsers": "uxcore-tools run browsers",
"saucelabs": "uxcore-tools run saucelabs",
"update": "uxcore-tools run update"
},
"bugs": {
"url": "http://github.com/uxcore/uxcore-steps/issues"
},
"keywords": [
"react",
"react-component",
"uxcore-steps",
"Steps"
],
"devDependencies": {
"console-polyfill": "^0.2.2",
"enzyme": "^2.6.0",
"es5-shim": "^4.5.8",
"eslint": "^3.9.1",
"eslint-config-airbnb": "^12.0.0",
"eslint-plugin-import": "^1.16.0",
"eslint-plugin-jsx-a11y": "^2.2.3",
"eslint-plugin-react": "^6.4.1",
"expect.js": "~0.3.1",
"kuma-base": "1.x",
"object-assign": "^4.1.0",
"react": "0.14.x",
"react-addons-test-utils": "0.14.x",
"react-dom": "0.14.x",
"uxcore-kuma": "*",
"uxcore-tools": "0.2.x"
},
"dependencies": {
"classnames": "^2.1.2",
"object-assign": "^4.0.0",
"uxcore-icon": "^0.1.15",
"uxcore-tooltip": "^0.4.5"
},
"contributors": [],
"license": "MIT"
}
"name": "uxcore-steps",
"version": "2.1.3",
"description": "uxcore-steps component for uxcore.",
"repository": "https://github.com/uxcore/uxcore-steps.git",
"author": "vincent.bian",
"main": "build/index.js",
"scripts": {
"start": "uxcore-tools run start",
"server": "uxcore-tools run server",
"lint": "uxcore-tools run lint",
"build": "uxcore-tools run build",
"test": "uxcore-tools run test",
"coverage": "uxcore-tools run coverage",
"pub": "uxcore-tools run pub",
"dep": "uxcore-tools run dep",
"tnpm-dep": "uxcore-tools run tnpm-dep",
"chrome": "uxcore-tools run chrome",
"browsers": "uxcore-tools run browsers",
"saucelabs": "uxcore-tools run saucelabs",
"update": "uxcore-tools run update",
"tnpm-update": "uxcore-tools run tnpm-update"
},
"bugs": {
"url": "http://github.com/uxcore/uxcore-steps/issues"
},
"keywords": [
"react",
"react-component",
"uxcore-steps",
"Steps"
],
"devDependencies": {
"console-polyfill": "^0.2.2",
"enzyme": "^3.0.0",
"enzyme-adapter-react-15": "^1.0.0",
"es5-shim": "^4.5.8",
"expect.js": "~0.3.1",
"kuma-base": "1.x",
"react": "15.x",
"react-dom": "15.x",
"react-test-renderer": "15.x",
"uxcore-kuma": "*",
"uxcore-tools": "0.2.x"
},
"dependencies": {
"classnames": "^2.1.2",
"object-assign": "^4.0.0",
"prop-types": "^15.6.0",
"uxcore-icon": "^0.1.15",
"uxcore-tooltip": "^0.4.5"
},
"contributors": [],
"license": "MIT"
}
5 changes: 3 additions & 2 deletions src/Step.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React, { Component, PropTypes } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import Icon from 'uxcore-icon';
import Tooltip from 'uxcore-tooltip';

class Step extends Component {
class Step extends React.Component {
constructor(props) {
super(props);

Expand Down
26 changes: 14 additions & 12 deletions src/Steps.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
* All rights reserved.
*/
import React from 'react';
import PropTypes from 'prop-types';

class Steps extends React.Component {
constructor(props) {
super(props);

this.state = {
init: false,
tailWidth: 0,
Expand Down Expand Up @@ -251,18 +253,18 @@ Steps.defaultProps = {
};

Steps.propTypes = {
prefixCls: React.PropTypes.string,
className: React.PropTypes.string,
iconPrefix: React.PropTypes.string,
maxDescriptionWidth: React.PropTypes.number,
current: React.PropTypes.number,
direction: React.PropTypes.string,
showIcon: React.PropTypes.bool,
type: React.PropTypes.oneOf(['default', 'title-on-top', 'long-desc', 'bottom-desc', 'arrow-bar']),
showDetail: React.PropTypes.bool,
currentDetail: React.PropTypes.number,
onChange: React.PropTypes.func,
children: React.PropTypes.any,
prefixCls: PropTypes.string,
className: PropTypes.string,
iconPrefix: PropTypes.string,
maxDescriptionWidth: PropTypes.number,
current: PropTypes.number,
direction: PropTypes.string,
showIcon: PropTypes.bool,
type: PropTypes.oneOf(['default', 'title-on-top', 'long-desc', 'bottom-desc', 'arrow-bar']),
showDetail: PropTypes.bool,
currentDetail: PropTypes.number,
onChange: PropTypes.func,
children: PropTypes.any,
};

Steps.displayName = 'Steps';
Expand Down
8 changes: 5 additions & 3 deletions tests/Step.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import expect from 'expect.js';
import { mount } from 'enzyme';
import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';
import React from 'react';

import Step from '../src/Step';

Enzyme.configure({ adapter: new Adapter() });

const generateStep = (status, title, desc, icon, options, type = 'default') => {
const wrapper = mount(
<Step
Expand Down Expand Up @@ -35,7 +38,6 @@ describe('Step', () => {
it('should display status finish', () => {
const w = generateStep('finish', '', '', '');
expect(w.find('.kuma-step-status-finish').length).to.be(1);
w.node.onIconClick();
});
it('should display status error', () => {
const w = generateStep('error', '', '', '');
Expand All @@ -51,7 +53,7 @@ describe('Step', () => {

it('should render description', () => {
const w = generateStep('finish', 'test', 'this is description', '', '', 'arrow-bar');
expect(w.find('.step-info').length).to.be(1);
expect(w.find('.step-info').length).to.above(0);
});
});

Expand Down
7 changes: 4 additions & 3 deletions tests/Steps.spec.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import expect from 'expect.js';
import { mount } from 'enzyme';
import Enzyme, { mount } from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';
import React from 'react';
import assign from 'object-assign';
import Steps from '../src';

Enzyme.configure({ adapter: new Adapter() });

const generateSteps = (options = {}) => {
const opts = assign({}, {
current: 1,
Expand Down Expand Up @@ -104,15 +107,13 @@ describe('Steps', () => {
describe('Render Vertically', () => {
it('render result should be correct with vertical param', () => {
const i = generateSteps({ direction: 'vertical' });
const html = i.html();
expect(i.find('.kuma-step-vertical').length).to.be(1);
});
});

describe('Render with Detail', () => {
it('render result should be correct with vertical param', () => {
const i = generateSteps({ showDetail: true });
const html = i.html();
i.instance().setState({ current: 2 });
expect(i.find('.kuma-step-vertical').length).to.be(0);
});
Expand Down

0 comments on commit dcc4d1b

Please sign in to comment.