Skip to content

Commit 81f39a6

Browse files
fix test
1 parent 8ef2167 commit 81f39a6

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

packages/react/__tests__/hooks/useChain.test.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
* @jest-environment jsdom
33
*/
44

5-
import { renderHook, act, waitFor } from '@testing-library/react';
6-
import { useChain } from '../../src/hooks/useChain';
7-
import { useWalletManager } from '../../src/hooks/useWalletManager';
85
import { ChainNameNotExist, WalletState } from '@interchain-kit/core';
6+
import { ChainWalletState, InterchainStore, WalletManagerStore } from '@interchain-kit/store';
7+
import { WalletStore } from '@interchain-kit/store';
8+
import { act, renderHook, waitFor } from '@testing-library/react';
99

10-
import { MockWallet } from '../helpers/mock-wallet';
1110
import { useWalletModal } from '../../src/hooks';
12-
import { WalletManagerStore, ChainWalletState, InterchainStore } from '@interchain-kit/store';
13-
import { WalletStore } from '@interchain-kit/store';
11+
import { useChain } from '../../src/hooks/useChain';
12+
import { useWalletManager } from '../../src/hooks/useWalletManager';
13+
import { MockWallet } from '../helpers/mock-wallet';
1414

1515
jest.mock('../../src/hooks/useWalletManager');
1616
jest.mock('../../src/hooks/useWalletModal.ts');
@@ -48,6 +48,7 @@ describe('useChain', () => {
4848
addAssetList: jest.fn(),
4949
getChainById: jest.fn(),
5050
getAssetListByChainId: jest.fn(),
51+
getWalletOfType: jest.fn(),
5152
} as jest.Mocked<WalletStore>;
5253

5354

@@ -95,7 +96,7 @@ describe('useChain', () => {
9596
getSigningClient: jest.fn(),
9697
getEnv: jest.fn(),
9798
getDownloadLink: jest.fn(),
98-
} as jest.Mocked<WalletManagerStore>
99+
} as jest.Mocked<WalletManagerStore>;
99100

100101
const mockWalletModal = {
101102
open: jest.fn(),
@@ -139,7 +140,7 @@ describe('useChain', () => {
139140
expect(result.current.username).toBe('test-user');
140141
expect(result.current.address).toBe('test-address');
141142
expect(result.current.rpcEndpoint).toBe('http://localhost:26657');
142-
})
143+
});
143144

144145

145146
});
@@ -157,7 +158,7 @@ describe('useChain', () => {
157158
await waitFor(() => {
158159
expect(mockWalletManager.setCurrentChainName).toHaveBeenCalledWith('test-chain');
159160
expect(mockWalletModal.open).toHaveBeenCalled();
160-
})
161+
});
161162
});
162163

163164
it('should call disconnect when disconnect is invoked', async () => {
@@ -173,7 +174,7 @@ describe('useChain', () => {
173174
await waitFor(() => {
174175

175176
expect(mockWalletManager.disconnect).toHaveBeenCalledWith('test-wallet', 'test-chain');
176-
})
177+
});
177178

178179
});
179180

@@ -190,7 +191,7 @@ describe('useChain', () => {
190191
await waitFor(() => {
191192
expect(mockWalletManager.setCurrentChainName).toHaveBeenCalledWith('test-chain');
192193
expect(mockWalletModal.open).toHaveBeenCalled();
193-
})
194+
});
194195

195196
});
196197

@@ -206,6 +207,6 @@ describe('useChain', () => {
206207

207208
await waitFor(() => {
208209
expect(mockWalletModal.close).toHaveBeenCalled();
209-
})
210+
});
210211
});
211212
});

packages/react/__tests__/modal/modal.test.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
* @jest-environment jsdom
33
*/
44

5+
import "@testing-library/jest-dom";
6+
7+
import { InterchainStore, WalletStore } from "@interchain-kit/store";
8+
import { fireEvent, render, screen } from "@testing-library/react";
59
import React from "react";
6-
import { render, screen, fireEvent } from "@testing-library/react";
10+
711
import {
8-
WalletModalElementProps,
912
WalletModalElement,
13+
WalletModalElementProps,
1014
} from "../../src/modal/modal";
11-
import "@testing-library/jest-dom";
1215
import { transferToWalletUISchema } from "../../src/utils";
1316
import { MockWallet } from "../helpers/mock-wallet";
14-
import { WalletStore, InterchainStore } from "@interchain-kit/store";
1517

1618
describe("WalletModal", () => {
1719
const mockWallet = new MockWallet({
@@ -45,6 +47,7 @@ describe("WalletModal", () => {
4547
addAssetList: jest.fn(),
4648
getChainById: jest.fn(),
4749
getAssetListByChainId: jest.fn(),
50+
getWalletOfType: jest.fn(),
4851
} as jest.Mocked<WalletStore>;
4952
const mockProps: WalletModalElementProps = {
5053
shouldShowList: false,

packages/store/__tests__/chain-wallet-store.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ describe('ChainWalletStore', () => {
197197
expect(mockInterchainStore.updateChainWalletState).toHaveBeenCalledWith(
198198
'keplr',
199199
'cosmoshub',
200-
{ walletState: WalletState.Connecting }
200+
{ walletState: WalletState.Connecting, errorMessage: '' }
201201
);
202202
expect(mockWallet.connect).toHaveBeenCalledWith('cosmoshub-4');
203203
expect(mockWallet.getAccount).toHaveBeenCalledWith('cosmoshub-4');
@@ -217,7 +217,7 @@ describe('ChainWalletStore', () => {
217217
expect(mockInterchainStore.updateChainWalletState).toHaveBeenCalledWith(
218218
'keplr',
219219
'cosmoshub',
220-
{ walletState: WalletState.Connecting }
220+
{ walletState: WalletState.Connecting, errorMessage: '' }
221221
);
222222
expect(mockInterchainStore.updateChainWalletState).toHaveBeenCalledWith(
223223
'keplr',

packages/store/src/wallet-manager/chain-wallet-store.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ export class ChainWalletStore extends BaseWallet {
5252
}
5353

5454
try {
55-
console.log(1);
5655
this.store.updateChainWalletState(this.wallet.info.name, this.chain.chainName, { walletState: WalletState.Connecting, errorMessage: '' });
5756
await this.wallet.connect(this.chain.chainId);
5857
const account = await this.getAccount();

0 commit comments

Comments
 (0)