Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
version: 2
jobs:
lint:
docker:
- image: circleci/node:latest
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm run lint
test:
docker:
- image: circleci/node:latest
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v1-dependencies-{{ checksum "package.json" }}
- run: npm install
- save_cache:
paths:
- node_modules
key: v1-dependencies-{{ checksum "package.json" }}
- run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash)
workflows:
version: 2
build_and_test:
jobs:
- lint
- test
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.storybook
.doc
node_modules
coverage/
2 changes: 1 addition & 1 deletion now.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"src": "package.json",
"use": "@now/static-build",
"config": { "distDir": "build" }
"config": { "distDir": ".doc" }
}
]
}
23 changes: 3 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,10 @@
"gh-pages": "rc-tools run gh-pages",
"start1": "rc-tools run storybook",
"pub": "rc-tools run pub --babel-runtime",
"lint": "rc-tools run lint",
"lint:fix": "rc-tools run lint --fix",
"test": "jest",
"coverage": "jest --coverage",
"lint": "eslint src/**/*",
"test": "father test",
"now-build": "npm run build"
},
"jest": {
"setupFiles": [
"./tests/setup.js"
],
"collectCoverageFrom": [
"src/**/*"
],
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"transform": {
"\\.jsx?$": "./node_modules/rc-tools/scripts/jestPreprocessor.js"
}
},
"peerDependencies": {
"react": "*"
},
Expand All @@ -62,8 +46,7 @@
"enzyme": "^3.1.0",
"enzyme-adapter-react-16": "^1.0.2",
"enzyme-to-json": "^3.1.4",
"father": "^2.6.2",
"jest": "^21.2.1",
"father": "^2.6.4",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-redux": "^4.4.10",
Expand Down
4 changes: 2 additions & 2 deletions src/utils/NameMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface KV<T> {
* NameMap like a `Map` but accepts `string[]` as key.
*/
class NameMap<T = any> {
private list: Array<KV<T>> = [];
private list: KV<T>[] = [];

public clone(): NameMap<T> {
const clone = new NameMap();
Expand Down Expand Up @@ -61,7 +61,7 @@ class NameMap<T = any> {
return null;
});

return json;
return json;
}
}

Expand Down
31 changes: 16 additions & 15 deletions src/utils/asyncUtil.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
export function allPromiseFinish(promiseList: Array<Promise<any>>) {
export function allPromiseFinish(promiseList: Promise<any>[]) {
let hasError = false;
let count = promiseList.length;
const results: any[] = [];

return new Promise((resolve, reject) => {
promiseList.forEach((promise, index) => {
promise
.catch((e) => {
hasError = true;
return e;
}).then((result) => {
count -= 1;
results[index] = result;
.catch(e => {
hasError = true;
return e;
})
.then(result => {
count -= 1;
results[index] = result;

if (count !== 0) {
return;
}
if (count !== 0) {
return;
}

if (hasError) {
reject(results);
}
resolve(results);
});
if (hasError) {
reject(results);
}
resolve(results);
});
});
});
}
2 changes: 1 addition & 1 deletion src/utils/valueUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { toArray } from './typeUtil';
* 123 => [123]
* ['a', 123] => ['a', 123]
*/
export function getNamePath(path: NamePath | null): Array<string | number> {
export function getNamePath(path: NamePath | null): (string | number)[] {
return toArray(path);
}

Expand Down
10 changes: 10 additions & 0 deletions tests/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { mount } from 'enzyme';
import Form from '../src';

describe('Basic', () => {
it('create form', () => {
const wrapper = mount(<Form />);
expect(wrapper.find('form')).toBeTruthy();
});
});