From 771e4b24e552e95c4e811f1960338bc7997c74bd Mon Sep 17 00:00:00 2001 From: abhishandy Date: Thu, 11 Jan 2024 22:01:18 -0500 Subject: [PATCH] Balance organism --- components/organisms/Wallet/Balance.test.js | 71 +++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 components/organisms/Wallet/Balance.test.js diff --git a/components/organisms/Wallet/Balance.test.js b/components/organisms/Wallet/Balance.test.js new file mode 100644 index 0000000..36710f8 --- /dev/null +++ b/components/organisms/Wallet/Balance.test.js @@ -0,0 +1,71 @@ +import '@testing-library/jest-dom'; +import { render, screen } from "@testing-library/react"; +import WalletBalance from "./Balance"; +import { SessionProvider } from "next-auth/react"; + +describe("WalletBalance", () => { + test("renders loading message when data is loading", () => { + render( + + + ); + const loadingMessage = screen.getByText("Loading..."); + expect(loadingMessage).toBeInTheDocument(); + }); + + test("renders wallet balance details when data is loaded", () => { + const sessionData = { + user: { + data: { + userId: "1234567890abcdef", + }, + }, + }; + const data = { + isLoading: false, + data: [ + { + type: "MOI", + amount: 100, + currency: "USD", + operations: [], + }, + { + type: "Other", + amount: 200, + currency: "EUR", + operations: [], + }, + ], + }; + + render( + + + + ); + + // Check if wallet balance details are rendered correctly + const walletId = screen.getByText("#12345678...0abcdef"); + expect(walletId).toBeInTheDocument(); + + const walletType = screen.getByText("POUR MOI"); + expect(walletType).toBeInTheDocument(); + + const walletAmount = screen.getByText("$100.00"); + expect(walletAmount).toBeInTheDocument(); + + }); + + // test("renders 'No savings currently in progress' message when data is loaded but no savings are available", () => { + // const data = { + // isLoading: false, + // data: [], + // }; + + // render(); + + // const noSavingsMessage = screen.getByText("Aucun épargne actuellement en cours..."); + // expect(noSavingsMessage).toBeInTheDocument(); + // }); +}); \ No newline at end of file