import { describe, it, expect, beforeEach } from 'vitest'; import { formTracking, isFormCaught, toggleFormCaught, markFormsCaught, } from '../src/store/formTracking.js'; beforeEach(() => { localStorage.clear(); formTracking.replace({ caught: {} }); }); describe('formTracking', () => { it('toggle flips a slug', () => { expect(isFormCaught('unown-c')).toBe(false); toggleFormCaught('unown-c'); expect(isFormCaught('unown-c')).toBe(true); toggleFormCaught('unown-c'); expect(isFormCaught('unown-c')).toBe(false); }); it('markFormsCaught sets a batch and never un-marks', () => { toggleFormCaught('unown-z'); // already caught markFormsCaught(['unown', 'unown-c', 'unown-z']); expect(isFormCaught('unown')).toBe(true); expect(isFormCaught('unown-c')).toBe(true); expect(isFormCaught('unown-z')).toBe(true); // stays caught expect(isFormCaught('unown-q')).toBe(false); // untouched }); it('markFormsCaught tolerates empty / missing input', () => { markFormsCaught([]); markFormsCaught(undefined); expect(formTracking.get().caught).toEqual({}); }); });