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
64 lines (60 loc) · 1.59 KB
/
Copy pathsetup.ts
File metadata and controls
64 lines (60 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
58
59
60
61
62
63
64
import "@testing-library/jest-dom";
import { vi } from "vitest";
import React from "react";
// 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 }),
}));
// Mock window.crypto for tests
Object.defineProperty(globalThis, "crypto", {
value: {
subtle: {
digest: async (_algorithm: string, data: ArrayBuffer) => {
const text = new TextDecoder().decode(data);
const hash = new Uint8Array(32);
for (let i = 0; i < text.length && i < 32; i++) {
hash[i] = text.charCodeAt(i);
}
return hash.buffer;
},
},
getRandomValues: (arr: Uint8Array) => {
for (let i = 0; i < arr.length; i++) {
arr[i] = Math.floor(Math.random() * 256);
}
return arr;
},
},
});
// 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");