Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Nov 13, 2023
1 parent 38905a6 commit 197caf3
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/services/walletconnect/__tests__/WalletConnectWallet.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ProposalTypes, SessionTypes, SignClientTypes, Verify } from '@wall
import type { IWeb3Wallet, Web3WalletTypes } from '@walletconnect/web3wallet'

import WalletConnectWallet from '../WalletConnectWallet'
import { SAFE_WALLET_METADATA } from '../constants'

jest.mock('@walletconnect/core', () => ({
Core: jest.fn(),
Expand Down Expand Up @@ -474,17 +475,24 @@ describe('WalletConnectWallet', () => {

describe('getActiveSessions', () => {
it('should return an array of active sessions', () => {
const session1 = {
topic: 'topic1',
namespaces: {},
self: { metadata: SAFE_WALLET_METADATA },
} as SessionTypes.Struct
const session2 = {
topic: 'topic2',
namespaces: {},
self: { metadata: { url: 'test.io' } },
} as SessionTypes.Struct
jest.spyOn((wallet as any).web3Wallet, 'getActiveSessions').mockReturnValue({
topic1: { topic: 'topic1', namespaces: {} } as SessionTypes.Struct,
topic2: { topic: 'topic2', namespaces: {} } as SessionTypes.Struct,
topic1: session1,
topic2: session2,
})

const activeSessions = wallet.getActiveSessions()

expect(activeSessions).toEqual([
{ topic: 'topic1', namespaces: {} },
{ topic: 'topic2', namespaces: {} },
])
expect(activeSessions).toEqual([session1])
})
})

Expand Down

0 comments on commit 197caf3

Please sign in to comment.