Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: switching networks should not disconnect wallets #198

Merged
merged 3 commits into from
Jul 2, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test(core): update WalletManager tests
  • Loading branch information
drichar committed Jul 2, 2024
commit af87a7b22e416ce2f828bd16c6ee904a47ae63fa
26 changes: 0 additions & 26 deletions packages/use-wallet/src/__tests__/manager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,36 +207,10 @@ describe('WalletManager', () => {
[WalletId.KIBISIS, mockKibisisWallet]
])

// Mock isConnected to return true
vi.spyOn(mockDeflyWallet, 'isConnected', 'get').mockReturnValue(true)
vi.spyOn(mockKibisisWallet, 'isConnected', 'get').mockReturnValue(true)

const disconnectMock = vi.spyOn(manager, 'disconnect')

await manager.setActiveNetwork(NetworkId.MAINNET)

expect(disconnectMock).toHaveBeenCalled()
expect(manager.activeNetwork).toBe(NetworkId.MAINNET)
})

it('does not call disconnect if the network is already active', async () => {
const manager = new WalletManager({
wallets: [WalletId.DEFLY, WalletId.KIBISIS]
})
manager._clients = new Map<WalletId, BaseWallet>([
[WalletId.DEFLY, mockDeflyWallet],
[WalletId.KIBISIS, mockKibisisWallet]
])

const disconnectMock = vi.spyOn(manager, 'disconnect')

// Set initial active network
manager.store.setState((state) => ({ ...state, activeNetwork: NetworkId.MAINNET }))

await manager.setActiveNetwork(NetworkId.MAINNET)

expect(disconnectMock).not.toHaveBeenCalled()
})
})

describe('subscribe', () => {
Expand Down
Loading