mirror of
https://github.com/AmanTahiliani/box-box.git
synced 2026-08-07 19:56:18 -04:00
Fourth view on the championship page: assign P1-P10 per remaining round and see projected standings update live, with position deltas and mathematically alive/eliminated title states. Pure projection logic in lib/simulator.ts (2025 points system, standard GPs only); scenarios persist to localStorage per season. 169 frontend tests passing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
30 lines
1003 B
TypeScript
30 lines
1003 B
TypeScript
import '@testing-library/jest-dom'
|
|
|
|
Object.defineProperty(window, 'scrollTo', {
|
|
value: () => {},
|
|
writable: true,
|
|
})
|
|
|
|
// Node 22+ ships an experimental `localStorage` global that shadows jsdom's
|
|
// implementation; without `--localstorage-file` it resolves to undefined in
|
|
// the test environment. Back-fill a minimal in-memory Storage so components
|
|
// that persist state (e.g. the championship simulator) are testable.
|
|
if (typeof window !== 'undefined' && !window.localStorage) {
|
|
const store = new Map<string, string>()
|
|
const localStorageMock: Storage = {
|
|
get length() {
|
|
return store.size
|
|
},
|
|
clear: () => store.clear(),
|
|
getItem: (key) => (store.has(key) ? store.get(key)! : null),
|
|
key: (index) => [...store.keys()][index] ?? null,
|
|
removeItem: (key) => {
|
|
store.delete(key)
|
|
},
|
|
setItem: (key, value) => {
|
|
store.set(String(key), String(value))
|
|
},
|
|
}
|
|
Object.defineProperty(window, 'localStorage', { value: localStorageMock, writable: true })
|
|
}
|