Skip to content

Commit 95bf157

Browse files
committed
test: update e2e-tests
1 parent 0486442 commit 95bf157

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

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

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,42 @@ describe('useContractQuery', () => {
1515
contract = new Contract<Psp22ContractApi>(client, psp22Metadata, contractAddress, { defaultCaller: ALICE });
1616
});
1717

18-
it('should load total supply', async () => {
19-
const { result } = renderHook(() => useContractQuery({ contract, fn: 'psp22TotalSupply' }), {
18+
it('should work probably', async () => {
19+
const { result: totalSupply } = renderHook(() => useContractQuery({ contract, fn: 'psp22TotalSupply' }), {
2020
wrapper,
2121
});
2222

23-
expect(result.current.data).toBeUndefined();
23+
expect(totalSupply.current.data).toBeUndefined();
24+
expect(totalSupply.current.isLoading).toEqual(true);
25+
expect(totalSupply.current.isRefreshing).toEqual(false);
26+
27+
await waitFor(() => {
28+
expect(totalSupply.current.data).toEqual(BigInt(1e20));
29+
expect(totalSupply.current.isLoading).toEqual(false);
30+
});
31+
32+
totalSupply.current.refresh();
33+
34+
await waitFor(() => {
35+
expect(totalSupply.current.isRefreshing).toEqual(true);
36+
});
37+
38+
await waitFor(() => {
39+
expect(totalSupply.current.data).toEqual(BigInt(1e20));
40+
expect(totalSupply.current.isRefreshing).toEqual(false);
41+
});
2442

43+
const { result: balanceOf } = renderHook(
44+
() => useContractQuery({ contract, args: ['0x_FAKE_'], fn: 'psp22BalanceOf' }),
45+
{
46+
wrapper,
47+
},
48+
);
2549
await waitFor(() => {
26-
expect(result.current.data).toBe(BigInt(1e20));
50+
expect(balanceOf.current.error).toBeDefined();
2751
});
52+
53+
console.log('Error:', balanceOf.current.error);
2854
});
2955

3056
it('should dry run successfully', async () => {
@@ -92,7 +118,7 @@ describe('useContractQuery', () => {
92118
},
93119
{ timeout: 12000 },
94120
);
95-
121+
96122
console.log('After transfer:', balanceOf.current.data);
97123
});
98124

0 commit comments

Comments
 (0)