Skip to content

Commit

Permalink
test: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency committed Aug 22, 2024
1 parent 1c4bc4f commit afff08a
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 79 deletions.
29 changes: 2 additions & 27 deletions components/bank/components/__tests__/historyBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 0 additions & 1 deletion components/bank/components/__tests__/sendBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const renderWithProps = (props = {}) => {
return renderWithChainProvider(<SendBox {...defaultProps} {...props} />);
};

// TODO: ALL FAILING
describe("SendBox", () => {
afterEach(() => {
cleanup();
Expand Down
35 changes: 1 addition & 34 deletions components/bank/components/__tests__/tokenList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
70 changes: 53 additions & 17 deletions tests/mock.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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" }],
},
},
];
Expand Down

0 comments on commit afff08a

Please sign in to comment.