feat: complete testing, security, dynamic content, and devops overhaul
This commit is contained in:
1 parent
467532713c
commit
40ff169dc2
52 files changed
+3918
-104
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import '@testing-library/jest-dom';
|
||||
import { vi } from 'vitest';
|
||||
|
||||
class LocalStorageMock {
|
||||
private store: Record<string, string> = {};
|
||||
|
||||
clear() {
|
||||
this.store = {};
|
||||
}
|
||||
|
||||
getItem(key: string) {
|
||||
return this.store[key] || null;
|
||||
}
|
||||
|
||||
setItem(key: string, value: string) {
|
||||
this.store[key] = String(value);
|
||||
}
|
||||
|
||||
removeItem(key: string) {
|
||||
delete this.store[key];
|
||||
}
|
||||
|
||||
get length() {
|
||||
return Object.keys(this.store).length;
|
||||
}
|
||||
|
||||
key(index: number) {
|
||||
return Object.keys(this.store)[index] || null;
|
||||
}
|
||||
}
|
||||
|
||||
const localStorageMock = new LocalStorageMock();
|
||||
Object.defineProperty(window, 'localStorage', {
|
||||
value: localStorageMock,
|
||||
writable: true,
|
||||
});
|
||||
|
||||
// Mock IntersectionObserver for framer-motion/motion viewport triggers
|
||||
class IntersectionObserverMock {
|
||||
readonly root: Element | null = null;
|
||||
readonly rootMargin: string = '';
|
||||
readonly thresholds: ReadonlyArray<number> = [];
|
||||
constructor(callback: any, options?: any) {}
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
takeRecords() { return []; }
|
||||
}
|
||||
Object.defineProperty(window, 'IntersectionObserver', {
|
||||
value: IntersectionObserverMock,
|
||||
writable: true,
|
||||
});
|
||||
|
||||
// Mock matchMedia if needed
|
||||
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(),
|
||||
})),
|
||||
});
|
||||
Reference in new issue
Block a user