From f83cd94cda35081a48d7cd693ca24f9fdf38c078 Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Sun, 26 Jul 2020 10:50:31 +0800 Subject: [PATCH] Improve test coverage Cover scenarios primarily for adjusted behavior on Button, as well as ensure components are exported correctly. --- .npmignore | 1 - .prettierrc | 2 +- lib/components/Button/Button.test.tsx | 64 ++++- lib/components/Button/Button.tsx | 218 ++++++++++----- lib/components/Checkbox/Checkbox.test.tsx | 3 + lib/components/Checkbox/Checkbox.tsx | 26 +- lib/components/Icon/Icon.test.tsx | 3 + lib/components/Icon/Icon.tsx | 21 +- .../RadioButton/RadioButton.test.tsx | 3 + lib/components/RadioButton/RadioButton.tsx | 61 +++-- lib/components/Select/Select.test.tsx | 30 +-- lib/components/Select/Select.tsx | 86 +++--- lib/components/Slider/Slider.test.tsx | 3 + lib/components/Slider/Slider.tsx | 74 ++--- lib/components/TextInput/TextInput.test.tsx | 45 +--- lib/components/TextInput/TextInput.tsx | 253 ++++++++---------- lib/index.test.ts | 26 ++ lib/services/isEmpty.test.ts | 18 +- lib/services/isEmpty.ts | 5 +- lib/services/splitValueAndUnit.test.ts | 41 +-- lib/services/splitValueAndUnit.ts | 6 +- lib/services/stringify.test.ts | 55 ++-- lib/services/stringify.ts | 8 +- package.json | 2 +- 24 files changed, 534 insertions(+), 520 deletions(-) create mode 100644 lib/index.test.ts diff --git a/.npmignore b/.npmignore index 54bdf08..30ba8a2 100644 --- a/.npmignore +++ b/.npmignore @@ -8,7 +8,6 @@ utilities/ .editorconfig .prettierrc doczrc.js -global.d.ts jest.config.js jest.setup.ts plopfile.js diff --git a/.prettierrc b/.prettierrc index 75c93d5..3380468 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,6 +4,6 @@ "printWidth": 120, "semi": false, "trailingComma": "all", - "quoteProps": "consistent", + "quoteProps": "as-needed", "arrowParens": "always" } diff --git a/lib/components/Button/Button.test.tsx b/lib/components/Button/Button.test.tsx index e2c1b70..c2f286c 100644 --- a/lib/components/Button/Button.test.tsx +++ b/lib/components/Button/Button.test.tsx @@ -1,16 +1,17 @@ +/// +/// + import * as fc from 'fast-check' import * as Enzyme from 'enzyme' import * as Axe from 'jest-axe' import * as React from 'react' -import Button, { Variant } from './Button' +import Button, { Variant, ButtonElement } from './Button' import stringify from '../../services/stringify' const CUSTOM_VARIANTS: string[] = ['primary'] const AVAILABLE_VARIANTS: string[] = ['outline', 'primary'] -const BLOCK_DISPLAYS = ['block', 'grid', 'flex', 'table'] - it('should exist', () => { expect(Button).toBeDefined() }) @@ -23,21 +24,46 @@ it('should render without crashing given minimum required props', () => { expect(() =>