Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions __tests__/components/cards/Wallet.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import CardsWallet from "@/components/cards/Wallet";
import "@testing-library/jest-dom";
import { mockWallet } from "../../../__mocks__/fixtures/wallet";
import { renderWithRedux } from "../../../__mocks__/renderWithRedux";
import { screen } from "@testing-library/react";


// use the actual component when it is done tested
jest.mock("../../../src/components/sections/profile/modals/EditAddress/index.tsx", () => {
return <h1>hello</h1>;
});

describe("Wallet card component", () => {
it("renders the wallet component with all the required elements", () => {
renderWithRedux(<CardsWallet wallet={mockWallet} disabled={false} />);
expect(screen.getByTestId("cardWalletId")).toBeInTheDocument()
expect(screen.getByText("User wallet")).toBeInTheDocument();
expect(screen.getByTestId("tag-value")).toBeInTheDocument();
expect(screen.queryAllByTestId("currencyId")).not.toBeNull();
expect(screen.getByTestId("coin")).toBeInTheDocument();
});
});
5 changes: 3 additions & 2 deletions src/components/cards/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { openVerificationModal } from "@/store/feature/kyc.slice";
interface CardsWalletProps {
wallet: Wallet;
disabled?: boolean;
testId?:string
}

/**
Expand All @@ -28,7 +29,7 @@ interface CardsWalletProps {
* @returns {ReactElement}
*/

export default function CardsWallet({ wallet, disabled = false }: CardsWalletProps): ReactElement {
export default function CardsWallet({ wallet, disabled = false, testId='cardWalletId' }: CardsWalletProps): ReactElement {
const { t } = useTranslation();
const [showEditModal, setShowEditModal] = useState(false);
const [showPayoutModal, setShowPayoutModal] = useState(false);
Expand Down Expand Up @@ -74,7 +75,7 @@ export default function CardsWallet({ wallet, disabled = false }: CardsWalletPro
};

return (
<div className="relative mb-7">
<div className="relative mb-7" data-testid={testId}>
<div className="relative lg:flex md:flex sm:flex rounded-3.5xl">
{showEditModal && <EditAddress show={showEditModal} onClose={onClose} wallet={wallet} />}
<Payout wallet={wallet} show={showPayoutModal} onClose={onClose} />
Expand Down