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
58 lines (53 loc) · 1.58 KB
/
Copy pathsetup.ts
File metadata and controls
58 lines (53 loc) · 1.58 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
58
import "@testing-library/jest-dom";
import { vi } from "vitest";
import React from "react";
import crypto from "node:crypto";
// Mock Next.js router
vi.mock("next/navigation", () => ({
useRouter: () => ({
push: vi.fn(),
replace: vi.fn(),
back: vi.fn(),
forward: vi.fn(),
refresh: vi.fn(),
prefetch: 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 subtle = crypto.webcrypto?.subtle ?? (globalThis.crypto && globalThis.crypto.subtle);
const getRandomValues = (arr: Uint8Array) => (crypto.webcrypto ? crypto.webcrypto.getRandomValues(arr) : (globalThis.crypto ? globalThis.crypto.getRandomValues(arr) : arr));
if (!globalThis.crypto || !globalThis.crypto.subtle) {
Object.defineProperty(globalThis, "crypto", {
value: {
subtle,
getRandomValues,
},
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");