From bfa23c182fad6c5f7ab595926f1552e74405a19d Mon Sep 17 00:00:00 2001 From: Volodymyr Kozieiev Date: Wed, 29 Nov 2023 18:50:49 +0000 Subject: [PATCH] Add requirement for component tests (#18015) --- doc/new-guidelines.md | 2 +- src/quo/README.md | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/doc/new-guidelines.md b/doc/new-guidelines.md index b61f38eba3..a1e8d0f517 100644 --- a/doc/new-guidelines.md +++ b/doc/new-guidelines.md @@ -716,7 +716,7 @@ src - `src/js`: Raw Javascript files, e.g. React Native Reanimated worklets. - `src/mocks`: Plumbing configuration to be able to run tests. -- `src/quo/`: The component library for Status Mobile. +- `src/quo/`: The component library for Status Mobile. [Read more...](../src/quo/README.md) - `src/react_native/`: Contains only low-level constructs to help React Native work in tandem with Clojure(Script). - `src/status_im2/`: Directory where we try to be as strict as possible about diff --git a/src/quo/README.md b/src/quo/README.md index 9f29132283..d2bb142321 100644 --- a/src/quo/README.md +++ b/src/quo/README.md @@ -116,6 +116,17 @@ rendered. We use [React Native Testing Library](https://callstack.github.io/reac There are dozens of examples in the repository, so use them as a reference. A good and complete example is [quo.components.avatars.user-avatar.component-spec](/src/quo/components/avatars/user_avatar/component_spec.cljs) +### No-props test + +When writing tests for the component that has props, please add one test that covers situation when props aren't passed. Because even if component not showing anything meaningful without props, it shouldn't crash. + +```clojure +(h/describe "Transaction Progress" + (h/test "component renders without props" + (h/render [quo/transaction-progress {}]) + (h/is-truthy (h/get-by-label-text :transaction-progress))) +``` + ## Do not couple the library with re-frame Don't use re-frame inside this library (e.g. dispatch & subscribe). If a