From 3fed773280d140302a043f22494ec8779c1f494c Mon Sep 17 00:00:00 2001 From: Chris Duncan Date: Mon, 14 Oct 2024 02:23:07 -0700 Subject: [PATCH] Check for existing global session storage prior to mocking in tests. --- test/TEST_VECTORS.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) 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' -- 2.34.1