diff --git a/__tests__/store/store.test.ts b/__tests__/store/store.test.ts index cb3d764..9005bcd 100644 --- a/__tests__/store/store.test.ts +++ b/__tests__/store/store.test.ts @@ -1,10 +1,31 @@ -import { Mock, beforeEach, describe, expect, it } from 'bun:test' +import { Mock, beforeEach, describe, expect, it, spyOn } from 'bun:test' import { NetworkId } from 'src/network/constants' import { StoreActions, StoreMutations, createStore, defaultState } from 'src/store' import { LOCAL_STORAGE_KEY } from 'src/store/constants' import { replacer } from 'src/store/utils' import { WalletId } from 'src/wallets/supported/constants' +// Suppress console output +spyOn(console, 'info').mockImplementation(() => {}) +spyOn(console, 'warn').mockImplementation(() => {}) +spyOn(console, 'error').mockImplementation(() => {}) +spyOn(console, 'groupCollapsed').mockImplementation(() => {}) + +// Mock localStorage +const localStorageMock = (() => { + let store: Record = {} + return { + getItem: (key: string) => store[key] || null, + setItem: (key: string, value: any) => (store[key] = value.toString()), + clear: () => (store = {}) + } +})() +if (!localStorage) { + Object.defineProperty(global, 'localStorage', { + value: localStorageMock + }) +} + describe('Store', () => { beforeEach(() => { localStorage.clear() diff --git a/__tests__/wallets/manager.test.ts b/__tests__/wallets/manager.test.ts index 253fb6e..0de9e4e 100644 --- a/__tests__/wallets/manager.test.ts +++ b/__tests__/wallets/manager.test.ts @@ -22,9 +22,11 @@ const localStorageMock = (() => { clear: () => (store = {}) } })() -Object.defineProperty(global, 'localStorage', { - value: localStorageMock -}) +if (!localStorage) { + Object.defineProperty(global, 'localStorage', { + value: localStorageMock + }) +} const deflyResumeSession = spyOn(DeflyWallet.prototype, 'resumeSession').mockImplementation(() => Promise.resolve()