Skip to content

Commit a686d67

Browse files
committed
Refactor test
1 parent bbaa540 commit a686d67

File tree

5 files changed

+38
-71
lines changed

5 files changed

+38
-71
lines changed

src/__tests__/chain-config.spec.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { describe, expect, it } from "vitest";
2+
import { getChainConfig, getChainConfigs } from "../utils";
3+
import { createPublicClient, http } from "viem";
4+
import abi from "../abi/erc20";
5+
6+
describe.each(getChainConfigs(true).filter((c) => !!c.tokens.length))("$name", ({ tokens, ...chain }) => {
7+
const publicClient = createPublicClient({ chain, transport: http() });
8+
9+
it("Should configure native token", () => {
10+
expect(tokens.some((t) => t.type === "native")).not.toBeFalsy();
11+
});
12+
13+
describe.each(tokens.filter((t) => !!t.cross.length))("$symbol", (token) => {
14+
it.each(token.cross)(
15+
`The target chain should not be configured as the source chain: '${chain.network}' => $target.network`,
16+
(cross) => {
17+
expect(cross.target.network).not.toBe(chain.network);
18+
},
19+
);
20+
21+
it.each(token.cross)("The target chain should already be configured: $target.network", (cross) => {
22+
expect(getChainConfig(cross.target.network)).toBeDefined();
23+
});
24+
25+
it.each(token.cross)("The target token should already be configured: $target.symbol", (cross) => {
26+
expect(getChainConfig(cross.target.network)?.tokens.find((t) => t.symbol === cross.target.symbol)).toBeDefined();
27+
});
28+
29+
it.skipIf(chain.network === "taiko")(`Should configure the correct decimals: '${token.decimals}'`, async () => {
30+
if (token.type === "native") {
31+
expect(token.decimals).toEqual(18);
32+
} else {
33+
const decimals = await publicClient.readContract({ address: token.address, abi, functionName: "decimals" });
34+
expect(token.decimals).toEqual(decimals);
35+
}
36+
});
37+
});
38+
});

src/__tests__/native-token.spec.ts

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/__tests__/target-chain.spec.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

src/__tests__/target-token.spec.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/__tests__/token-decimals.spec.ts

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)