forked from TheSoftwareDevGuild/TheGuildGenesis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppWrapper.test.tsx
More file actions
54 lines (49 loc) · 1.48 KB
/
Copy pathAppWrapper.test.tsx
File metadata and controls
54 lines (49 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
import { AppWrapper } from "@/components/AppWrapper";
import React from "react";
// Mock window.matchMedia
Object.defineProperty(window, "matchMedia", {
writable: true,
value: vi.fn().mockImplementation((query) => ({
matches: false,
media: query,
onchange: null,
addListener: vi.fn(), // deprecated
removeListener: vi.fn(), // deprecated
addEventListener: vi.fn(),
removeEventListener: vi.fn(),
dispatchEvent: vi.fn(),
})),
});
// Mock wagmi
vi.mock("wagmi", () => ({
WagmiProvider: ({ children }: { children: React.ReactNode }) => (
<div>{children}</div>
),
useAccount: () => ({ address: undefined }),
useSignMessage: () => ({ signMessageAsync: vi.fn() }),
}));
// Mock RainbowKit
vi.mock("@rainbow-me/rainbowkit", () => ({
ConnectButton: () => <div data-testid="connect-button">Connect Wallet</div>,
RainbowKitProvider: ({ children }: { children: React.ReactNode }) => (
<div>{children}</div>
),
getDefaultConfig: () => ({}),
}));
// Mock the wagmi config getter
vi.mock("@/lib/wagmi", () => ({
getWagmiConfig: () => ({}),
}));
describe("AppWrapper", () => {
it("renders title and connect button", () => {
render(
<AppWrapper>
<div>Test</div>
</AppWrapper>
);
expect(screen.getByText("The Guild Genesis")).toBeInTheDocument();
expect(screen.getByTestId("connect-button")).toBeInTheDocument();
});
});