feat(pwa): Online-Status-Store
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m31s
All checks were successful
Build & Publish Docker Image / build-and-push (push) Successful in 1m31s
Reaktiver Store basierend auf navigator.onLine und den window- Events online/offline. Kein aktives Heuristik-Probing — für unseren Offline-PWA-Use-Case reicht der Browser-Status. Wird von SyncIndicator und require-online-Helper konsumiert. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
23
tests/unit/network-store.test.ts
Normal file
23
tests/unit/network-store.test.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
// @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);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user