// @vitest-environment jsdom import { describe, it, expect, beforeEach } from 'vitest'; describe('network store', () => { beforeEach(() => { // Reset module state for each test Object.defineProperty(navigator, 'onLine', { value: true, configurable: true }); }); it('reflects initial navigator.onLine and reacts to events', async () => { const { network } = await import('../../src/lib/client/network.svelte'); network.init(); expect(network.online).toBe(true); Object.defineProperty(navigator, 'onLine', { value: false, configurable: true }); window.dispatchEvent(new Event('offline')); expect(network.online).toBe(false); Object.defineProperty(navigator, 'onLine', { value: true, configurable: true }); window.dispatchEvent(new Event('online')); expect(network.online).toBe(true); }); });