From 4648926084b05858b6a66b434aa5ac23eb8c547a Mon Sep 17 00:00:00 2001 From: zombiej Date: Mon, 10 Jun 2019 15:20:44 +0800 Subject: [PATCH 1/6] update deps --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7f8fbc62..c03e36c8 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "enzyme": "^3.1.0", "enzyme-adapter-react-16": "^1.0.2", "enzyme-to-json": "^3.1.4", - "father": "^2.6.2", + "father": "^2.6.3", "jest": "^21.2.1", "react": "^16.8.6", "react-dom": "^16.8.6", From 00169df960f9cfa312c2a163ddeeaaabb9f2c968 Mon Sep 17 00:00:00 2001 From: zombiej Date: Mon, 10 Jun 2019 15:45:33 +0800 Subject: [PATCH 2/6] rm jest --- package.json | 17 +---------------- tests/index.test.js | 5 +++++ 2 files changed, 6 insertions(+), 16 deletions(-) create mode 100644 tests/index.test.js diff --git a/package.json b/package.json index c03e36c8..0781e374 100644 --- a/package.json +++ b/package.json @@ -35,24 +35,10 @@ "pub": "rc-tools run pub --babel-runtime", "lint": "rc-tools run lint", "lint:fix": "rc-tools run lint --fix", - "test": "jest", + "test": "father test", "coverage": "jest --coverage", "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": "*" }, @@ -63,7 +49,6 @@ "enzyme-adapter-react-16": "^1.0.2", "enzyme-to-json": "^3.1.4", "father": "^2.6.3", - "jest": "^21.2.1", "react": "^16.8.6", "react-dom": "^16.8.6", "react-redux": "^4.4.10", diff --git a/tests/index.test.js b/tests/index.test.js new file mode 100644 index 00000000..37083cbe --- /dev/null +++ b/tests/index.test.js @@ -0,0 +1,5 @@ +describe('Basic', () => { + it('test', () => { + console.log(666); + }); +}); From 03a7b4a46f671aca663a7b5ac878565c61dfd1b8 Mon Sep 17 00:00:00 2001 From: zombiej Date: Mon, 10 Jun 2019 15:47:55 +0800 Subject: [PATCH 3/6] use father build dir --- now.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/now.json b/now.json index 136ba0e6..5419edd9 100644 --- a/now.json +++ b/now.json @@ -5,7 +5,7 @@ { "src": "package.json", "use": "@now/static-build", - "config": { "distDir": "build" } + "config": { "distDir": ".doc" } } ] } From cecd9fe5388a6941959442f807b0dd67ae2b69cb Mon Sep 17 00:00:00 2001 From: zombiej Date: Mon, 10 Jun 2019 16:28:12 +0800 Subject: [PATCH 4/6] first test --- .circleci/config.yml | 37 +++++++++++++++++++++++++++++++++++++ .gitignore | 1 + package.json | 6 ++---- src/utils/NameMap.ts | 2 +- src/utils/asyncUtil.ts | 31 ++++++++++++++++--------------- src/utils/valueUtil.ts | 2 +- tests/index.test.js | 9 +++++++-- 7 files changed, 65 insertions(+), 23 deletions(-) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000..08501de0 --- /dev/null +++ b/.circleci/config.yml @@ -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 +workflows: + version: 2 + build_and_test: + jobs: + - lint + - test \ No newline at end of file diff --git a/.gitignore b/.gitignore index bb6f664e..1098b56c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .storybook .doc node_modules +coverage/ \ No newline at end of file diff --git a/package.json b/package.json index 0781e374..c7ab5dbf 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,8 @@ "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", + "lint": "eslint src/**/*", "test": "father test", - "coverage": "jest --coverage", "now-build": "npm run build" }, "peerDependencies": { @@ -48,7 +46,7 @@ "enzyme": "^3.1.0", "enzyme-adapter-react-16": "^1.0.2", "enzyme-to-json": "^3.1.4", - "father": "^2.6.3", + "father": "^2.6.4", "react": "^16.8.6", "react-dom": "^16.8.6", "react-redux": "^4.4.10", diff --git a/src/utils/NameMap.ts b/src/utils/NameMap.ts index 85b5b02f..710ef51c 100644 --- a/src/utils/NameMap.ts +++ b/src/utils/NameMap.ts @@ -10,7 +10,7 @@ interface KV { * NameMap like a `Map` but accepts `string[]` as key. */ class NameMap { - private list: Array> = []; + private list: KV[] = []; public clone(): NameMap { const clone = new NameMap(); diff --git a/src/utils/asyncUtil.ts b/src/utils/asyncUtil.ts index 83cd91e5..661b705d 100644 --- a/src/utils/asyncUtil.ts +++ b/src/utils/asyncUtil.ts @@ -1,4 +1,4 @@ -export function allPromiseFinish(promiseList: Array>) { +export function allPromiseFinish(promiseList: Promise[]) { let hasError = false; let count = promiseList.length; const results: any[] = []; @@ -6,22 +6,23 @@ export function allPromiseFinish(promiseList: Array>) { 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); + }); }); }); } diff --git a/src/utils/valueUtil.ts b/src/utils/valueUtil.ts index b83f0bf3..01f4efe2 100644 --- a/src/utils/valueUtil.ts +++ b/src/utils/valueUtil.ts @@ -10,7 +10,7 @@ import { toArray } from './typeUtil'; * 123 => [123] * ['a', 123] => ['a', 123] */ -export function getNamePath(path: NamePath | null): Array { +export function getNamePath(path: NamePath | null): (string | number)[] { return toArray(path); } diff --git a/tests/index.test.js b/tests/index.test.js index 37083cbe..bf995e1a 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -1,5 +1,10 @@ +import React from 'react'; +import { mount } from 'enzyme'; +import Form from '../src'; + describe('Basic', () => { - it('test', () => { - console.log(666); + it('create form', () => { + const wrapper = mount(
); + expect(wrapper.find('form')).toBeTruthy(); }); }); From e85201fd367261ba1a12dd231ccdc8be745ab3bc Mon Sep 17 00:00:00 2001 From: zombiej Date: Mon, 10 Jun 2019 16:28:35 +0800 Subject: [PATCH 5/6] first test --- src/utils/NameMap.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/NameMap.ts b/src/utils/NameMap.ts index 710ef51c..dc2e7484 100644 --- a/src/utils/NameMap.ts +++ b/src/utils/NameMap.ts @@ -61,7 +61,7 @@ class NameMap { return null; }); - return json; + return json; } } From 39ad96cac76fbb257d8f47bf72410df468ac5a02 Mon Sep 17 00:00:00 2001 From: zombiej Date: Mon, 10 Jun 2019 16:33:49 +0800 Subject: [PATCH 6/6] add codecov --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 08501de0..c10f9d15 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -28,7 +28,7 @@ jobs: paths: - node_modules key: v1-dependencies-{{ checksum "package.json" }} - - run: npm test -- --coverage + - run: npm test -- --coverage && bash <(curl -s https://codecov.io/bash) workflows: version: 2 build_and_test: