/** * Stub Nuxt auto-imports ที่ composable ใช้ — เบากว่าการลาก @nuxt/test-utils ทั้งชุดเข้ามา * - useState: ตาม semantics ของ Nuxt คือ state แชร์กันตาม key (สร้างครั้งแรก ครั้งถัดไปได้ตัวเดิม) * - computed: ของ vue ตรงๆ * เคลียร์ state ทุก test เพื่อไม่ให้ theme ของ test ก่อนหน้ารั่วมา */ import { beforeEach } from 'vitest' import { computed, ref, type Ref } from 'vue' const sharedState = new Map>() ;(globalThis as Record).useState = (key: string, init: () => T): Ref => { let entry = sharedState.get(key) if (!entry) { entry = ref(init()) as Ref sharedState.set(key, entry) } return entry as Ref } ;(globalThis as Record).computed = computed beforeEach(() => { sharedState.clear() document.documentElement.classList.remove('dark') localStorage.clear() })