From 3c95220db4d4a969932f5fdf0fe61c77f6fa93df Mon Sep 17 00:00:00 2001 From: kailang Date: Wed, 12 Jun 2019 10:54:50 +0800 Subject: [PATCH] feat: Add test coverage --- .travis.yml | 6 ------ docs/content/components/badge.mdx | 2 ++ package.json | 4 +++- src/components/Badge/index.test.tsx | 4 ++++ src/{setupTests.js => setupTests.ts} | 6 +++--- 5 files changed, 12 insertions(+), 10 deletions(-) rename src/{setupTests.js => setupTests.ts} (80%) diff --git a/.travis.yml b/.travis.yml index dd09a12d..1b58d9b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,9 +12,3 @@ jobs: - stage: "Tests" name: "Unit Tests" script: yarn test - -script: - - git config --global user.name "wangkailang" - - git config --global user.email "2418904055@qq.com" - - echo "machine github.com login wangkailang password c7202e7c76a3b7f74b48d21b370aeb594bdecf02" > ~/.netrc - - cd docs && yarn && yarn deploy && cd .. diff --git a/docs/content/components/badge.mdx b/docs/content/components/badge.mdx index 034e38b0..e54e3ced 100644 --- a/docs/content/components/badge.mdx +++ b/docs/content/components/badge.mdx @@ -62,7 +62,9 @@ date: 2019-05-21 ```jsx
+ +
``` diff --git a/package.json b/package.json index 1321cd2e..e830d128 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "typescript": "3.4.5" }, "scripts": { - "test": "react-scripts test", + "test": "react-scripts test --env=jsdom", + "coverage": "yarn test --coverage --watchAll=false", "storybook": "start-storybook -p 6006 -c .storybook", "build-storybook": "build-storybook -s ./stories/public -c .storybook -o build-stories" }, @@ -43,6 +44,7 @@ "@storybook/react": "^5.0.11", "@types/classnames": "^2.2.8", "@types/enzyme": "^3.9.3", + "@types/enzyme-adapter-react-16": "^1.0.5", "@types/react-bootstrap": "^0.32.17", "classnames": "^2.2.6", "enzyme": "^3.10.0", diff --git a/src/components/Badge/index.test.tsx b/src/components/Badge/index.test.tsx index 995a180c..8e5c8012 100644 --- a/src/components/Badge/index.test.tsx +++ b/src/components/Badge/index.test.tsx @@ -28,4 +28,8 @@ describe('Badge', () => { const badge = shallow(UI); expect(badge.find('.Badge__wrapper').exists()).toEqual(true); }); + it('badge showing dot with text', () => { + const badge = shallow(); + expect(badge.find('.Badge__dot').exists()).toEqual(true); + }); }) diff --git a/src/setupTests.js b/src/setupTests.ts similarity index 80% rename from src/setupTests.js rename to src/setupTests.ts index cae96bb3..496c4cd2 100644 --- a/src/setupTests.js +++ b/src/setupTests.ts @@ -2,9 +2,9 @@ * https://github.com/xsky-fe/create-react-app-wizard/blob/master/packages/react-scripts/scripts/utils/createJestConfig.js#L28 * https://github.com/facebook/create-react-app/blob/master/packages/react-scripts/template/README.md#testing-components **/ -import { configure } from 'enzyme'; +import Enzyme from 'enzyme'; import Adapter from 'enzyme-adapter-react-16'; -configure ({ - adapter: new Adapter (), +Enzyme.configure ({ + adapter: new Adapter(), })