From 66beba4235f88725a537ece546e8e25468bbcea2 Mon Sep 17 00:00:00 2001 From: "a.bouhuolia" Date: Sun, 5 Jun 2022 16:41:49 +0200 Subject: [PATCH] chore(MarketTransactions): Add some assertions to the component. --- .../components/atoms/Currency/Currency.tsx | 6 +- .../MarketTransactionsTable.test.tsx | 16 +++- .../MarketTransactionsTableCell.tsx | 2 +- ... => MarketTransactionsTable.test.tsx.snap} | 78 +++++++++++++------ .../MarketTransactionsTable/_types.ts | 1 + 5 files changed, 73 insertions(+), 30 deletions(-) rename packages/renderer/src/components/molecules/MarketTransactionsTable/__snapshots__/{MarketTransactions.test.tsx.snap => MarketTransactionsTable.test.tsx.snap} (55%) diff --git a/packages/renderer/src/components/atoms/Currency/Currency.tsx b/packages/renderer/src/components/atoms/Currency/Currency.tsx index 6271d2d..1babd8c 100644 --- a/packages/renderer/src/components/atoms/Currency/Currency.tsx +++ b/packages/renderer/src/components/atoms/Currency/Currency.tsx @@ -15,18 +15,19 @@ // ============================================================================= import { useMemo } from "react"; +import type { FormatNumberOptions } from "react-intl"; import { useIntl } from "react-intl"; type CurrencyFormatType = "symbol" | "code" | "name" | "narrowSymbol"; -interface CurrencyProps { +interface CurrencyProps extends FormatNumberOptions { currencyCode?: string; currentDisplay?: CurrencyFormatType; value: number; } export function Currency(props: CurrencyProps) { - const { currencyCode, currentDisplay, value } = props; + const { currencyCode, currentDisplay, value, ...formatNumberProps } = props; const intl = useIntl(); const formattedNumber = useMemo( @@ -43,6 +44,7 @@ export function Currency(props: CurrencyProps) { minimumFractionDigits: 2, maximumFractionDigits: 12, }), + ...formatNumberProps, }), [currencyCode, value] ); diff --git a/packages/renderer/src/components/molecules/MarketTransactionsTable/MarketTransactionsTable.test.tsx b/packages/renderer/src/components/molecules/MarketTransactionsTable/MarketTransactionsTable.test.tsx index 6d5274a..f38870e 100644 --- a/packages/renderer/src/components/molecules/MarketTransactionsTable/MarketTransactionsTable.test.tsx +++ b/packages/renderer/src/components/molecules/MarketTransactionsTable/MarketTransactionsTable.test.tsx @@ -63,8 +63,8 @@ describe("molecules::MarketTransactionsTable", () => { ); - expect(screen.queryByText("7,564.94 XMR")).toBeInTheDocument(); - expect(screen.queryByText("6,483.23 XMR")).toBeInTheDocument(); + expect(screen.queryByText("XMR 7,564.94")).toBeInTheDocument(); + expect(screen.queryByText("XMR 6,483.23")).toBeInTheDocument(); unmount(); }); @@ -89,6 +89,16 @@ describe("molecules::MarketTransactionsTable", () => { expect(screen.queryByText("1,212")).toBeInTheDocument(); unmount(); }); + + it("renders offer formatted payment method.", () => { + const { unmount } = render( + + + + ); + expect(screen.queryByText("Cash by mail")).toBeInTheDocument(); + unmount(); + }); }); const data = [ @@ -112,7 +122,7 @@ const data = [ amountCurrency: "XMR", cost: 983.32, costCurrency: "USD", - paymentMethod: MarketTransactionPaymentMethod.CashByMail, + paymentMethod: MarketTransactionPaymentMethod.Other, accountAge: 12, accountTrades: 3412, }, diff --git a/packages/renderer/src/components/molecules/MarketTransactionsTable/MarketTransactionsTableCell.tsx b/packages/renderer/src/components/molecules/MarketTransactionsTable/MarketTransactionsTableCell.tsx index 4c6adb9..8fa596b 100644 --- a/packages/renderer/src/components/molecules/MarketTransactionsTable/MarketTransactionsTableCell.tsx +++ b/packages/renderer/src/components/molecules/MarketTransactionsTable/MarketTransactionsTableCell.tsx @@ -90,7 +90,7 @@ export function MarketTransactionsAccountTradesCell({ }) { return ( - + ); } diff --git a/packages/renderer/src/components/molecules/MarketTransactionsTable/__snapshots__/MarketTransactions.test.tsx.snap b/packages/renderer/src/components/molecules/MarketTransactionsTable/__snapshots__/MarketTransactionsTable.test.tsx.snap similarity index 55% rename from packages/renderer/src/components/molecules/MarketTransactionsTable/__snapshots__/MarketTransactions.test.tsx.snap rename to packages/renderer/src/components/molecules/MarketTransactionsTable/__snapshots__/MarketTransactionsTable.test.tsx.snap index e2dc4ce..2f8bc3d 100644 --- a/packages/renderer/src/components/molecules/MarketTransactionsTable/__snapshots__/MarketTransactions.test.tsx.snap +++ b/packages/renderer/src/components/molecules/MarketTransactionsTable/__snapshots__/MarketTransactionsTable.test.tsx.snap @@ -1,9 +1,9 @@ // Vitest Snapshot v1 -exports[`organisms::MarketTransactions > renders without exploding. 1`] = ` +exports[`molecules::MarketTransactionsTable > renders without exploding. 1`] = ` @@ -51,7 +51,7 @@ exports[`organisms::MarketTransactions > renders without exploding. 1`] = ` style="width: 400px;" >
renders without exploding. 1`] = ` €5,000.96
-1%
@@ -68,7 +68,11 @@ exports[`organisms::MarketTransactions > renders without exploding. 1`] = `
@@ -117,7 +133,7 @@ exports[`organisms::MarketTransactions > renders without exploding. 1`] = ` style="width: 400px;" >
renders without exploding. 1`] = ` €9,637.41
-1%
@@ -134,7 +150,11 @@ exports[`organisms::MarketTransactions > renders without exploding. 1`] = `
diff --git a/packages/renderer/src/components/molecules/MarketTransactionsTable/_types.ts b/packages/renderer/src/components/molecules/MarketTransactionsTable/_types.ts index bd1b41f..eaabf89 100644 --- a/packages/renderer/src/components/molecules/MarketTransactionsTable/_types.ts +++ b/packages/renderer/src/components/molecules/MarketTransactionsTable/_types.ts @@ -29,4 +29,5 @@ export interface MarketTransaction { export enum MarketTransactionPaymentMethod { CashByMail = "CashByMail", + Other = "Other", }
- XMR 7,564.94 +
+ XMR 7,564.94 +
renders without exploding. 1`] = ` - ASD +
+ Cash by mail +
-
- X -
+ +
65 Days
@@ -108,7 +124,7 @@ exports[`organisms::MarketTransactions > renders without exploding. 1`] = `
- 1,212.00 + 1,212
- XMR 6,483.23 +
+ XMR 6,483.23 +
renders without exploding. 1`] = ` - ASD +
-
- X -
+ +
65 Days
@@ -174,7 +204,7 @@ exports[`organisms::MarketTransactions > renders without exploding. 1`] = `
- 3,412.00 + 3,412