Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
8 changes: 6 additions & 2 deletions apps/dapp/frontend/__tests__/auth-provider.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ vi.mock("@/components/wallet-provider", () => ({
}));

function AuthConsumer() {
const { token, setToken } = useAuth();
const { token } = useAuth();
return (
<div>
<span data-testid="token">{token ?? "none"}</span>
<button onClick={() => setToken("jwt-test")}>Set Token</button>
<button onClick={() => {
window.localStorage.setItem("nester_auth_token", "jwt-test");
window.dispatchEvent(new StorageEvent("storage", { key: "nester_auth_token", newValue: "jwt-test" }));
}}>Set Token</button>
</div>
);
}
Expand All @@ -38,6 +41,7 @@ describe("AuthProvider", () => {
isConnected: false,
wallets: [],
walletsLoaded: true,
selectedWalletId: null,
} as ReturnType<typeof useWallet>);

render(
Expand Down
2 changes: 2 additions & 0 deletions apps/dapp/frontend/__tests__/connect-wallet.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ vi.mock("@/components/wallet-provider", () => ({
walletsLoaded: true,
isConnected: false,
address: null,
selectedWalletId: null,
})),
}));

Expand Down Expand Up @@ -60,6 +61,7 @@ describe("ConnectWallet", () => {
walletsLoaded: true,
isConnected: true,
address: "GABC1234567890",
selectedWalletId: "freighter",
} as ReturnType<typeof useWallet>);

render(<ConnectWallet />);
Expand Down
20 changes: 18 additions & 2 deletions apps/dapp/frontend/__tests__/deposit-modal.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, it, expect, vi } from "vitest";
import { render, screen, fireEvent } from "@testing-library/react";
import { DepositModal } from "@/components/vault/depositModal";
import { VAULTS } from "@/lib/mock-vaults";
import type { Vault as VaultType } from "@/lib/types/vault";

vi.mock("@/components/wallet-provider", () => ({
useWallet: () => ({
Expand All @@ -25,7 +25,23 @@ vi.mock("@/lib/stellar/transaction", () => ({
truncateTxHash: (h: string) => h.slice(0, 8),
}));

const mockVault = VAULTS[0];
const mockVault: VaultType = {
id: "usdc",
name: "USDC Market",
description: "Test market",
marketType: "single",
tokens: ["USDC"],
currentApy: 10,
apyRange: "8-12%",
tvl: 1000000,
utilization: 80,
allocations: [],
supportedAssets: ["USDC"],
maturityTerms: "Flexible",
earlyWithdrawalPenalty: "None",
apyHistory: [],
strategies: []
};

describe("DepositModal", () => {
it("validates amount input", () => {
Expand Down
Loading
Loading