From b90e80eb48d777237918e5e8413bbf7db4ac7618 Mon Sep 17 00:00:00 2001 From: Lucio Rubens <4539235+luciorubeens@users.noreply.github.com> Date: Mon, 29 Jun 2020 08:19:58 -0300 Subject: [PATCH 1/3] refactor: add empty mode to `WalletRegistrations` --- .../WalletRegistrations.stories.tsx | 2 + .../WalletRegistrations.test.tsx | 13 +- .../WalletRegistrations.tsx | 115 +++++++++++------- .../WalletRegistrations.test.tsx.snap | 52 ++++++-- 4 files changed, 125 insertions(+), 57 deletions(-) diff --git a/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.stories.tsx b/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.stories.tsx index 9f4674c83f..d2108fcbbb 100644 --- a/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.stories.tsx +++ b/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.stories.tsx @@ -15,3 +15,5 @@ export const Default = () => ( isMultisig /> ); + +export const Empty = () => ; diff --git a/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.test.tsx b/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.test.tsx index 308c79b9e1..8e04f8e9f2 100644 --- a/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.test.tsx +++ b/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.test.tsx @@ -4,17 +4,12 @@ import React from "react"; import { WalletRegistrations } from "./WalletRegistrations"; describe.only("WalletRegistrations", () => { - it("should render blank", () => { - const { asFragment } = render(); - expect(asFragment()).toMatchSnapshot(); - }); - it("should emit actions", () => { const onShowAll = jest.fn(); const onRegister = jest.fn(); const { getByTestId } = render( - , + , ); fireEvent.click(getByTestId("WalletRegistrations__show-all")); fireEvent.click(getByTestId("WalletRegistrations__register")); @@ -62,4 +57,10 @@ describe.only("WalletRegistrations", () => { const { getByTestId } = render(); expect(getByTestId("WalletRegistrations__business")).toHaveTextContent("Test"); }); + + it("should render empty mode", () => { + const { getByTestId, asFragment } = render(); + expect(getByTestId("WalletRegistrations__empty")).toBeTruthy(); + expect(asFragment()).toMatchSnapshot(); + }); }); diff --git a/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.tsx b/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.tsx index 65d93b21d4..a9d9a83a39 100644 --- a/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.tsx +++ b/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.tsx @@ -73,6 +73,8 @@ export const WalletRegistrations = ({ isMultisig && "Multisig", ].filter(Boolean); + const hasNoRegistrations = !delegate && !business && iconsList.length === 0; + return (
@@ -86,55 +88,84 @@ export const WalletRegistrations = ({
-
- {delegate && ( -
-
- - - - -
-
-

Delegate

-

- {delegate?.username} -

-
+ {hasNoRegistrations ? ( +
+
+ + + +
- )} +
+

Type Registrations

+

+ You haven't registered more than one type of registration. + + Learn More + +

+
+
+ ) : ( +
+ {delegate && ( +
+
+ + + + +
+
+

Delegate

+

+ {delegate?.username} +

+
+
+ )} - {business && ( -
-
- - - + {business && ( +
+
+ + + +
+
+

Business

+

+ {business?.name} +

+
-
-

Business

-

- {business?.name} -

+ )} + + {iconsList.length && ( +
+
-
- )} + )} +
+ )} - {iconsList.length && ( -
- -
+
+ {!hasNoRegistrations && ( + )} -
-
- diff --git a/src/domains/wallet/components/WalletRegistrations/__snapshots__/WalletRegistrations.test.tsx.snap b/src/domains/wallet/components/WalletRegistrations/__snapshots__/WalletRegistrations.test.tsx.snap index 711d342274..f1e701b362 100644 --- a/src/domains/wallet/components/WalletRegistrations/__snapshots__/WalletRegistrations.test.tsx.snap +++ b/src/domains/wallet/components/WalletRegistrations/__snapshots__/WalletRegistrations.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`WalletRegistrations should render blank 1`] = ` +exports[`WalletRegistrations should render empty mode 1`] = `
- 0 +
+
+
+ + delegate.svg + +
+
+
+
+
+

+ Type Registrations +

+

+ You haven't registered more than one type of registration. + + Learn More + +

+
-
From 8cd8df4f52d36f8d6cd5ff7f70bb63f28e6fd59b Mon Sep 17 00:00:00 2001 From: luciorubeens Date: Mon, 29 Jun 2020 11:30:46 +0000 Subject: [PATCH 3/3] style: resolve style guide violations --- .../components/WalletRegistrations/WalletRegistrations.tsx | 2 +- .../__snapshots__/WalletRegistrations.test.tsx.snap | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.tsx b/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.tsx index a9d9a83a39..613796376d 100644 --- a/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.tsx +++ b/src/domains/wallet/components/WalletRegistrations/WalletRegistrations.tsx @@ -100,7 +100,7 @@ export const WalletRegistrations = ({

Type Registrations

You haven't registered more than one type of registration. - + Learn More

diff --git a/src/domains/wallet/components/WalletRegistrations/__snapshots__/WalletRegistrations.test.tsx.snap b/src/domains/wallet/components/WalletRegistrations/__snapshots__/WalletRegistrations.test.tsx.snap index f1e701b362..4113bf0883 100644 --- a/src/domains/wallet/components/WalletRegistrations/__snapshots__/WalletRegistrations.test.tsx.snap +++ b/src/domains/wallet/components/WalletRegistrations/__snapshots__/WalletRegistrations.test.tsx.snap @@ -81,7 +81,7 @@ exports[`WalletRegistrations should render empty mode 1`] = ` > You haven't registered more than one type of registration. Learn More