]> zoso.dev Git - libnemo.git/commitdiff
Check for existing global session storage prior to mocking in tests.
authorChris Duncan <chris@zoso.dev>
Mon, 14 Oct 2024 09:23:07 +0000 (02:23 -0700)
committerChris Duncan <chris@zoso.dev>
Mon, 14 Oct 2024 09:23:07 +0000 (02:23 -0700)
test/TEST_VECTORS.js

index 655c0cb20e3c4f80cff391c46c62cdcdeb3cf894..b985050a9c3ef55fbe76a8517713d31bfceebb38 100644 (file)
@@ -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'