From: Chris Duncan Date: Mon, 14 Oct 2024 09:23:07 +0000 (-0700) Subject: Check for existing global session storage prior to mocking in tests. X-Git-Tag: v0.0.10~4 X-Git-Url: https://zoso.dev/?a=commitdiff_plain;h=3fed773280d140302a043f22494ec8779c1f494c;p=libnemo.git Check for existing global session storage prior to mocking in tests. --- diff --git a/test/TEST_VECTORS.js b/test/TEST_VECTORS.js index 655c0cb..b985050 100644 --- a/test/TEST_VECTORS.js +++ b/test/TEST_VECTORS.js @@ -2,18 +2,20 @@ // SPDX-License-Identifier: GPL-3.0-or-later export const STORAGE = (() => { - const _sessionStorage = {} - Object.defineProperty(globalThis, 'sessionStorage', { - value: { - length: Object.entries(_sessionStorage).length, - setItem: (key, value) => _sessionStorage[key] = value, - getItem: (key) => _sessionStorage[key], - removeItem: (key) => delete _sessionStorage[key], - clear: () => _sessionStorage = {} - }, - configurable: true, - enumerable: true - }) + if (globalThis.sessionStorage == null) { + const _sessionStorage = {} + Object.defineProperty(globalThis, 'sessionStorage', { + value: { + length: Object.entries(_sessionStorage).length, + setItem: (key, value) => _sessionStorage[key] = value, + getItem: (key) => _sessionStorage[key], + removeItem: (key) => delete _sessionStorage[key], + clear: () => _sessionStorage = {} + }, + configurable: true, + enumerable: true + }) + } })() export const GENESIS_ADDRESS = 'nano_3t6k35gi95xu6tergt6p69ck76ogmitsa8mnijtpxm9fkcm736xtoncuohr3'