Skip to content

Commit cbf6706

Browse files
committed
add psp22 hook test
1 parent d83e567 commit cbf6706

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

e2e/zombienet/src/hooks/useContract2.test.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { beforeAll, describe, expect, it } from 'vitest';
2-
import { ALICE, deployPsp22Contract, psp22Metadata } from '../utils';
2+
import { ALICE, deployPsp22Contract, psp22Metadata, wrapper } from '../utils';
33
import { numberToHex } from 'dedot/utils';
44
import { Contract } from 'dedot/contracts';
55
import { Psp22ContractApi } from '../contracts/psp22';
6+
import { renderHook, waitFor } from '@testing-library/react';
7+
import { usePSP22Balance } from 'typink';
68

79
describe('useContract2', () => {
810
let contract: Contract<Psp22ContractApi>;
@@ -26,4 +28,19 @@ describe('useContract2', () => {
2628
console.log(`alice balance`, state);
2729
expect(state).toBeDefined();
2830
});
31+
32+
it('should load balance properly', async () => {
33+
const { result } = renderHook(
34+
() => usePSP22Balance({ contractAddress: contract.address.address(), address: ALICE }), // prettier-end-here
35+
{ wrapper },
36+
);
37+
38+
expect(result.current.data).toBeUndefined();
39+
40+
await waitFor(() => {
41+
expect(result.current.data).toBeDefined();
42+
});
43+
44+
expect(result.current.data).toBeGreaterThan(0n);
45+
});
2946
});

0 commit comments

Comments
 (0)