Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 67 additions & 67 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@
"deploy": "bash scripts/deploy.sh"
},
"devDependencies": {
"happy-dom": "^20.11.2",
"sass": "^1.102.0",
"happy-dom": "^20.11.6",
"sass": "^1.103.1",
"typescript": "~7.0.2",
"vite": "^8.2.1",
"vite": "^8.2.2",
"vite-plugin-singlefile": "^2.3.3",
"vitest": "^4.1.10"
"vitest": "^4.1.11"
},
"dependencies": {
"lucide-static": "^1.31.0"
"lucide-static": "^1.42.0"
}
}
16 changes: 12 additions & 4 deletions src/ts/storage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import type { AppState, NetworkMap } from './types';
// that can't go through saveState.
const KEY = 'netgraph-state';

// happy-dom under vitest doesn't supply a working `localStorage`, so storage.ts
// (which uses the bare `localStorage` global) has nothing to read or write.
// Install a minimal in-memory Storage so the real load/save/migrate paths run.
// We want a clean in-memory `localStorage` per test, so storage.ts (which uses
// the bare `localStorage` global) exercises the real load/save/migrate paths.
// Older vitest's happy-dom env supplied no working localStorage at all; vitest 5
// defines a getter-only one on the window, which a plain assignment throws
// against - so install it with defineProperty, which works in both.
function makeStorage(): Storage {
const m = new Map<string, string>();
return {
Expand All @@ -25,7 +27,13 @@ function map(over: Partial<NetworkMap> = {}): NetworkMap {
return { id: 'm1', name: 'Map', devices: [], links: [], createdAt: 't', updatedAt: 't', ...over };
}

beforeEach(() => { globalThis.localStorage = makeStorage(); });
beforeEach(() => {
Object.defineProperty(globalThis, 'localStorage', {
value: makeStorage(),
configurable: true,
writable: true,
});
});
afterEach(() => vi.restoreAllMocks());

// -- createEmptyMap ----------------------------------------------
Expand Down