Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency committed Feb 6, 2025
1 parent 135038d commit 1ed0bc4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
21 changes: 1 addition & 20 deletions components/bank/components/__tests__/sendBox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@ mock.module('next/image', () => ({
},
}));

// Add this mock at the top of your test file
mock.module('@/components/bank/forms/ibcSendForm', () => ({
default: (props: any) => {
return (
<div data-testid="ibc-send-form">
<div className="dropdown">
<label tabIndex={0} aria-label="from-chain-selector" className="btn">
{props.selectedFromChain?.name || 'Select Chain'}
</label>
</div>
<div className="dropdown">
<label tabIndex={0} aria-label="to-chain-selector" className="btn">
{props.selectedToChain?.name || 'Select Chain'}
</label>
</div>
</div>
);
},
}));

const renderWithProps = (props = {}) => {
const defaultProps = {
address: 'test_address',
Expand All @@ -63,6 +43,7 @@ const renderWithProps = (props = {}) => {
describe('SendBox', () => {
afterEach(() => {
cleanup();
mock.restore();
});

test('renders correctly', () => {
Expand Down
1 change: 1 addition & 0 deletions components/bank/components/__tests__/tokenList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ expect.extend(matchers);
describe('TokenList', () => {
afterEach(() => {
cleanup();
mock.restore();
});

test('renders correctly', () => {
Expand Down
7 changes: 5 additions & 2 deletions components/bank/forms/__tests__/ibcSendForm.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { describe, test, afterEach, expect, jest, mock } from 'bun:test';
import { describe, test, afterEach, expect, jest, mock, beforeAll } from 'bun:test';
import React from 'react';
import { screen, cleanup, fireEvent, act } from '@testing-library/react';
import IbcSendForm from '@/components/bank/forms/ibcSendForm';
Expand Down Expand Up @@ -78,7 +78,10 @@ function renderWithProps(props = {}) {
}

describe('IbcSendForm Component', () => {
afterEach(cleanup);
afterEach(() => {
cleanup();
mock.restore();
});

test('renders form with correct details', async () => {
const { findForm } = renderWithProps();
Expand Down
5 changes: 4 additions & 1 deletion components/bank/forms/__tests__/sendForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ function renderWithProps(props = {}) {
}

describe('SendForm Component', () => {
afterEach(cleanup);
afterEach(() => {
cleanup();
mock.restore();
});

test('renders form with correct details', () => {
renderWithProps();
Expand Down

0 comments on commit 1ed0bc4

Please sign in to comment.