forked from Movalabs-crew/mova-store
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.ts
More file actions
57 lines (52 loc) · 1.59 KB
/
Copy pathsetup.ts
File metadata and controls
57 lines (52 loc) · 1.59 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
55
56
57
import "@testing-library/jest-dom";
import { vi } from "vitest";
import React from "react";
const nodeCrypto = require("crypto");
// Ensure test environment for React/Testing Library
// @ts-ignore
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
if (typeof process !== "undefined" && process.env) {
process.env.NODE_ENV = "test";
}
// Mock Next.js router
vi.mock("next/navigation", () => ({
useRouter: () => ({
push: vi.fn(),
replace: vi.fn(),
back: vi.fn(),
forward: vi.fn(),
refresh: vi.fn(),
}),
useSearchParams: () => ({
get: vi.fn(),
}),
usePathname: () => "/",
}));
// Mock Next.js Image component
vi.mock("next/image", () => ({
default: ({ src, alt, ...props }: { src: string; alt: string; [key: string]: unknown }) =>
React.createElement("img", { src, alt, ...props }),
}));
// Replace fake crypto mock with REAL SHA-256 via Node webcrypto
const realWebCrypto = (nodeCrypto as any).webcrypto || nodeCrypto;
Object.defineProperty(globalThis, "crypto", {
value: realWebCrypto,
writable: true,
configurable: true,
});
if (typeof window !== "undefined") {
Object.defineProperty(window, "crypto", {
value: realWebCrypto,
writable: true,
configurable: true,
});
}
// Mock environment variables
vi.stubEnv("NEXT_PUBLIC_STELLAR_NETWORK", "testnet");
vi.stubEnv(
"NEXT_PUBLIC_CHECKOUT_CONTRACT_ID",
"CTEST00000000000000000000000000000000000000000000000000"
);
vi.stubEnv("NEXT_PUBLIC_ADMIN_EMAILS", "admin@test.com,admin2@test.com");
vi.stubEnv("NEXT_PUBLIC_SUPABASE_URL", "https://dummy.supabase.co");
vi.stubEnv("NEXT_PUBLIC_SUPABASE_ANON_KEY", "dummy_anon_key");