Add tests for error handling in storage operations

This commit is contained in:
2026-03-31 01:51:03 +02:00
parent 4df1773c95
commit 2170d0ccd6
2 changed files with 40 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { describe, expect, it, vi } from "vitest";
import { describe, expect, it } from "vitest";
import { SCENE_DOCUMENT_VERSION, createEmptySceneDocument } from "../../src/document/scene-document";
import {
@@ -35,7 +35,7 @@ class ThrowingStorage implements KeyValueStorage {
} = {}
) {}
getItem(): string | null {
getItem(_key: string): string | null {
if (this.options.onGetItem !== undefined) {
throw this.options.onGetItem;
}
@@ -43,13 +43,13 @@ class ThrowingStorage implements KeyValueStorage {
return null;
}
setItem(): void {
setItem(_key: string, _value: string): void {
if (this.options.onSetItem !== undefined) {
throw this.options.onSetItem;
}
}
removeItem(): void {
removeItem(_key: string): void {
if (this.options.onRemoveItem !== undefined) {
throw this.options.onRemoveItem;
}
@@ -88,6 +88,8 @@ describe("local draft storage", () => {
} finally {
if (originalDescriptor !== undefined) {
Object.defineProperty(window, "localStorage", originalDescriptor);
} else {
Reflect.deleteProperty(window, "localStorage");
}
}
});