From afff08afd2d87d859ce06c76c8c07753c4c8559b Mon Sep 17 00:00:00 2001 From: "Felix C. Morency" <1102868+fmorency@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:27:36 -0400 Subject: [PATCH] test: cleanup --- .../components/__tests__/historyBox.test.tsx | 29 +------- .../components/__tests__/sendBox.test.tsx | 1 - .../components/__tests__/tokenList.test.tsx | 35 +--------- tests/mock.ts | 70 ++++++++++++++----- 4 files changed, 56 insertions(+), 79 deletions(-) diff --git a/components/bank/components/__tests__/historyBox.test.tsx b/components/bank/components/__tests__/historyBox.test.tsx index 87230faf..52a567c2 100644 --- a/components/bank/components/__tests__/historyBox.test.tsx +++ b/components/bank/components/__tests__/historyBox.test.tsx @@ -2,36 +2,11 @@ import { test, expect, afterEach, describe } from "bun:test"; import React from "react"; import matchers from "@testing-library/jest-dom/matchers"; import {render, screen, cleanup} from "@testing-library/react"; -import { - HistoryBox, - TransactionGroup, -} from "@/components/bank/components/historyBox"; +import {HistoryBox} from "@/components/bank/components/historyBox"; +import {mockTransactions} from "@/tests/mock"; expect.extend(matchers); -const mockTransactions: TransactionGroup[] = [ - { - tx_hash: "hash1", - block_number: 1, - formatted_date: "2023-05-01T12:00:00Z", - data: { - from_address: "address1", - to_address: "address2", - amount: [{ amount: "1000000", denom: "utoken" }], - }, - }, - { - tx_hash: "hash2", - block_number: 2, - formatted_date: "2023-05-02T12:00:00Z", - data: { - from_address: "address2", - to_address: "address1", - amount: [{ amount: "2000000", denom: "utoken" }], - }, - }, -]; - describe("HistoryBox", () => { afterEach(() => { cleanup(); diff --git a/components/bank/components/__tests__/sendBox.test.tsx b/components/bank/components/__tests__/sendBox.test.tsx index ced79c4e..f61e0967 100644 --- a/components/bank/components/__tests__/sendBox.test.tsx +++ b/components/bank/components/__tests__/sendBox.test.tsx @@ -18,7 +18,6 @@ const renderWithProps = (props = {}) => { return renderWithChainProvider(); }; -// TODO: ALL FAILING describe("SendBox", () => { afterEach(() => { cleanup(); diff --git a/components/bank/components/__tests__/tokenList.test.tsx b/components/bank/components/__tests__/tokenList.test.tsx index 5c4a7a3b..2725f0ec 100644 --- a/components/bank/components/__tests__/tokenList.test.tsx +++ b/components/bank/components/__tests__/tokenList.test.tsx @@ -3,43 +3,10 @@ import React from "react"; import matchers from '@testing-library/jest-dom/matchers'; import {fireEvent, render, screen, cleanup} from "@testing-library/react"; import TokenList from "@/components/bank/components/tokenList"; -import { CombinedBalanceInfo } from "@/pages/bank"; +import {mockBalances} from "@/tests/mock"; expect.extend(matchers); -const mockBalances: CombinedBalanceInfo[] = [ - { - denom: "token1", - coreDenom: "utoken1", - amount: "1000", - metadata: { - description: "My First Token", - name: "Token 1", - symbol: "TK1", - uri: "", - uri_hash: "", - display: "Token 1", - base: "token1", - denom_units: [{ denom: "utoken1", exponent: 0, aliases: ["utoken1"] }, { denom: "token1", exponent: 6, aliases: ["token1"] }], - }, - }, - { - denom: "token2", - coreDenom: "utoken2", - amount: "2000", - metadata: { - description: "My Second Token", - name: "Token 2", - symbol: "TK2", - uri: "", - uri_hash: "", - display: "Token 2", - base: "token2", - denom_units: [{ denom: "utoken2", exponent: 0, aliases: ["utoken2"] }, { denom: "token2", exponent: 6, aliases: ["token2"] }], - }, - }, -]; - describe("TokenList", () => { afterEach(() => { cleanup(); diff --git a/tests/mock.ts b/tests/mock.ts index 2177b0c2..7b6131d6 100644 --- a/tests/mock.ts +++ b/tests/mock.ts @@ -1,8 +1,42 @@ import {Chain} from "@chain-registry/types"; import {BondStatus} from "@chalabi/manifestjs/dist/codegen/cosmos/staking/v1beta1/staking"; -import {ExtendedValidatorSDKType} from "@/components"; +import {ExtendedValidatorSDKType, TransactionGroup} from "@/components"; import {CombinedBalanceInfo} from "@/pages/bank"; +export const mockBalances: CombinedBalanceInfo[] = [ + { + denom: "token1", + coreDenom: "utoken1", + amount: "1000", + metadata: { + description: "My First Token", + name: "Token 1", + symbol: "TK1", + uri: "", + uri_hash: "", + display: "Token 1", + base: "token1", + denom_units: [{ denom: "utoken1", exponent: 0, aliases: ["utoken1"] }, { denom: "token1", exponent: 6, aliases: ["token1"] }], + }, + }, + { + denom: "token2", + coreDenom: "utoken2", + amount: "2000", + metadata: { + description: "My Second Token", + name: "Token 2", + symbol: "TK2", + uri: "", + uri_hash: "", + display: "Token 2", + base: "token2", + denom_units: [{ denom: "utoken2", exponent: 0, aliases: ["utoken2"] }, { denom: "token2", exponent: 6, aliases: ["token2"] }], + }, + }, +]; + + export const mockActiveValidators: ExtendedValidatorSDKType[] = [ { operator_address: "validator1", @@ -116,23 +150,25 @@ export const defaultChain: Chain = { }, } -export const mockBalances: CombinedBalanceInfo[] = [ +export const mockTransactions: TransactionGroup[] = [ { - denom: "token1", - coreDenom: "utoken1", - amount: "1000", - metadata: { - description: "My First Token", - name: "Token 1", - symbol: "TK1", - uri: "", - uri_hash: "", - display: "Token 1", - base: "token1", - denom_units: [ - { denom: "utoken1", exponent: 0, aliases: ["utoken1"] }, - { denom: "token1", exponent: 6, aliases: ["token1"] }, - ], + tx_hash: "hash1", + block_number: 1, + formatted_date: "2023-05-01T12:00:00Z", + data: { + from_address: "address1", + to_address: "address2", + amount: [{ amount: "1000000", denom: "utoken" }], + }, + }, + { + tx_hash: "hash2", + block_number: 2, + formatted_date: "2023-05-02T12:00:00Z", + data: { + from_address: "address2", + to_address: "address1", + amount: [{ amount: "2000000", denom: "utoken" }], }, }, ];