Skip to content

Commit fc5bafa

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

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

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

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,40 @@ 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+
expect(totalSupply.current.isRefreshing).toEqual(true);
35+
36+
await waitFor(() => {
37+
expect(totalSupply.current.data).toEqual(BigInt(1e20));
38+
expect(totalSupply.current.isRefreshing).toEqual(false);
39+
});
2440

41+
const { result: balanceOf } = renderHook(
42+
() => useContractQuery({ contract, args: ['0x_FAKE_'], fn: 'psp22BalanceOf' }),
43+
{
44+
wrapper,
45+
},
46+
);
2547
await waitFor(() => {
26-
expect(result.current.data).toBe(BigInt(1e20));
48+
expect(balanceOf.current.error).toBeDefined();
2749
});
50+
51+
console.log('Error:', balanceOf.current.error);
2852
});
2953

3054
it('should dry run successfully', async () => {
@@ -92,7 +116,7 @@ describe('useContractQuery', () => {
92116
},
93117
{ timeout: 12000 },
94118
);
95-
119+
96120
console.log('After transfer:', balanceOf.current.data);
97121
});
98122

0 commit comments

Comments
 (0)