From d2b8df726cb12f6b1ea21fd45e22c5db1903c7da Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Sun, 12 Dec 2021 18:46:55 +0800 Subject: [PATCH] Add tests, refactor Implement tests to increase code coverage The option module was modified to split components and avoid overloading. --- .gitignore | 3 +- docs/philosophy.md | 45 +++ jest.config.js | 11 + package.json | 4 +- .../ActionButton/ActionButton.test.tsx | 201 +++++++++++++ .../action/components/ActionButton/index.tsx | 24 +- src/modules/action/web-action-react.test.ts | 9 + src/modules/base-badge/index.ts | 42 +++ src/modules/base-button/index.ts | 6 - src/modules/base-checkcontrol/index.ts | 16 +- src/modules/base-textcontrol/index.ts | 14 +- src/modules/component-prop-utils/index.ts | 22 ++ src/modules/css-utils/index.test.ts | 69 +++-- .../MaskedTextInput/MaskedTextInput.test.tsx | 186 +++++++++++- .../components/MaskedTextInput/index.tsx | 12 +- .../MultilineTextInput.test.tsx | 180 +++++++++++- .../components/MultilineTextInput/index.tsx | 13 +- .../components/TextInput/TextInput.test.tsx | 198 ++++++++++++- .../freeform/components/TextInput/index.tsx | 13 +- .../freeform/web-freeform-react.test.ts | 11 + src/modules/info/components/Badge/index.tsx | 66 ----- .../components/Badge/Badge.test.tsx | 31 ++ .../information/components/Badge/index.tsx | 36 +++ src/modules/{info => information}/index.ts | 0 .../information/web-information-react.test.ts | 9 + .../components/LinkButton/LinkButton.test.tsx | 189 ++++++++++++ .../components/LinkButton/index.tsx | 16 +- .../navigation/web-navigation-react.test.ts | 9 + .../option/components/Checkbox/index.tsx | 277 ------------------ .../DropdownSelect/DropdownSelect.test.tsx | 265 +++++++++++++++++ .../components/DropdownSelect/index.tsx | 38 +-- .../RadioButton/RadioButton.test.tsx | 22 ++ .../option/components/RadioButton/index.tsx | 200 ++++--------- .../RadioTickBox/RadioTickBox.test.tsx | 20 ++ .../option/components/RadioTickBox/index.tsx | 89 ++++++ .../ToggleButton/ToggleButton.test.tsx | 32 ++ .../option/components/ToggleButton/index.tsx | 181 ++++++++++++ .../ToggleSwitch/ToggleSwitch.test.tsx | 20 ++ .../option/components/ToggleSwitch/index.tsx | 109 +++++++ .../ToggleTickBox/ToggleTickBox.test.tsx | 30 ++ .../option/components/ToggleTickBox/index.tsx | 122 ++++++++ src/modules/option/index.ts | 5 +- src/modules/option/web-option-react.test.ts | 14 + src/pages/categories/navigation/index.tsx | 2 +- src/pages/categories/option/index.tsx | 104 +++---- tsconfig.json | 3 +- tsconfig.test.json | 5 +- yarn.lock | 14 + 48 files changed, 2334 insertions(+), 653 deletions(-) create mode 100644 docs/philosophy.md create mode 100644 src/modules/action/components/ActionButton/ActionButton.test.tsx create mode 100644 src/modules/action/web-action-react.test.ts create mode 100644 src/modules/base-badge/index.ts create mode 100644 src/modules/component-prop-utils/index.ts create mode 100644 src/modules/freeform/web-freeform-react.test.ts delete mode 100644 src/modules/info/components/Badge/index.tsx create mode 100644 src/modules/information/components/Badge/Badge.test.tsx create mode 100644 src/modules/information/components/Badge/index.tsx rename src/modules/{info => information}/index.ts (100%) create mode 100644 src/modules/information/web-information-react.test.ts create mode 100644 src/modules/navigation/components/LinkButton/LinkButton.test.tsx create mode 100644 src/modules/navigation/web-navigation-react.test.ts delete mode 100644 src/modules/option/components/Checkbox/index.tsx create mode 100644 src/modules/option/components/RadioButton/RadioButton.test.tsx create mode 100644 src/modules/option/components/RadioTickBox/RadioTickBox.test.tsx create mode 100644 src/modules/option/components/RadioTickBox/index.tsx create mode 100644 src/modules/option/components/ToggleButton/ToggleButton.test.tsx create mode 100644 src/modules/option/components/ToggleButton/index.tsx create mode 100644 src/modules/option/components/ToggleSwitch/ToggleSwitch.test.tsx create mode 100644 src/modules/option/components/ToggleSwitch/index.tsx create mode 100644 src/modules/option/components/ToggleTickBox/ToggleTickBox.test.tsx create mode 100644 src/modules/option/components/ToggleTickBox/index.tsx create mode 100644 src/modules/option/web-option-react.test.ts diff --git a/.gitignore b/.gitignore index c84d20f..5a027a7 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,5 @@ yarn-error.log* # vercel .vercel -.idea/ \ No newline at end of file +.idea/ +coverage/ \ No newline at end of file diff --git a/docs/philosophy.md b/docs/philosophy.md new file mode 100644 index 0000000..c058199 --- /dev/null +++ b/docs/philosophy.md @@ -0,0 +1,45 @@ +# Tesseract Web + +## Rationale + +- Every component library makes their own conventions of component organization +- Graceful degradation through backwards compatibility with HTML controls is not the main focus + - In return, aspects such as accessibility may suffer since HTML controls are generally compliant to accessibility + considerations suggested by approved standards + - Emerging Web applications are at risk of deviating through said standards which can fragment the Web platform + implementation +- Hopefully we can inspire component development through the component organization we are proposing; + everyone can have their own implementations + - cf. Authoring (publishing interfaces) vs Dependency (coercing consumers to adapt to concrete implementations) + +## Ground Rules + +- Each component is an enhanced version of an HTML control (see [HTML enhancement](#html-enhancement)) +- Each component should only do one thing and one thing only in terms of purpose and appearance (contrast to HTML's + `` where its function is overloaded depending on its `type` attribute) +- Each component has decoupled styling, wherein each styling has their own API + - This styling API is then made cross-framework compatible + - This styling API allows use of dynamic styles (which then requires CSS-in-JS way of application) + +## HTML enhancement + +| HTML element | Tesseract counterpart | Remarks | +|----------------------------------------------------------------------------|-------------------------------|-----------------------------------------------------------------------| +| `