diff --git a/src/index.test.ts b/src/index.test.ts index 5c49c10..34ab0f5 100644 --- a/src/index.test.ts +++ b/src/index.test.ts @@ -1,4 +1,4 @@ -import { getLocalStorage } from "."; +import { getLocalStorage, getMemoryStorage } from "."; import { MemoryStorage, ScopedStorage } from "./basic"; import { BrowserLocalStorage } from "./browser"; import { NodeDirectoryStorage } from "./node"; @@ -41,3 +41,10 @@ describe(getLocalStorage, () => { expect(mockWarn).toHaveBeenCalledWith("No persistent storage available, using in-memory volatile storage"); }); }); + +describe(getMemoryStorage, () => { + it("returns a memory storage", () => { + const storage = getMemoryStorage(); + expect(storage).toBeInstanceOf(MemoryStorage); + }); +}); diff --git a/src/index.ts b/src/index.ts index 2c38cc2..f39440b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -17,3 +17,10 @@ export function getLocalStorage(appname: string): KeyValueStorage { } } } + +/** + * Récupère un stockage "mémoire" + */ +export function getMemoryStorage(): KeyValueStorage { + return new MemoryStorage(); +}