Skip to content

Commit

Permalink
feat!: all tx types & fees (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
fmorency authored Jan 31, 2025
1 parent db082ac commit d041b41
Show file tree
Hide file tree
Showing 67 changed files with 1,652 additions and 557 deletions.
Binary file modified bun.lockb
Binary file not shown.
6 changes: 3 additions & 3 deletions components/admins/modals/__tests__/validatorModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('ValidatorDetailsModal Component', () => {
});
});

test('enables update button when input is valid', async () => {
test('enables upgrade button when input is valid', async () => {
renderWithProps();
const input = screen.getByPlaceholderText('1000');
fireEvent.change(input, { target: { value: '2000' } });
Expand All @@ -58,7 +58,7 @@ describe('ValidatorDetailsModal Component', () => {
});
});

test('disables update button when input is invalid', async () => {
test('disables upgrade button when input is invalid', async () => {
renderWithProps();
const input = screen.getByPlaceholderText('1000');
fireEvent.change(input, { target: { value: '-1' } });
Expand All @@ -82,7 +82,7 @@ describe('ValidatorDetailsModal Component', () => {
});
});

test('shows warning message for unsafe power update', async () => {
test('shows warning message for unsafe power upgrade', async () => {
renderWithProps();
const input = screen.getByPlaceholderText('1000');
fireEvent.change(input, { target: { value: '9000' } });
Expand Down
54 changes: 34 additions & 20 deletions components/bank/components/__tests__/historyBox.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect, afterEach, describe, mock, jest } from 'bun:test';
import { screen, cleanup, fireEvent } from '@testing-library/react';
import { HistoryBox } from '../historyBox';
import { renderWithChainProvider } from '@/tests/render';
import { mockTransactions } from '@/tests/mock';
import { HistoryBox } from '../historyBox';
import matchers from '@testing-library/jest-dom/matchers';

expect.extend(matchers);
Expand Down Expand Up @@ -52,7 +52,7 @@ describe('HistoryBox', () => {
);
});

test('displays transactions', () => {
test('displays transactions as `address1`', () => {
renderWithChainProvider(
<HistoryBox
isLoading={false}
Expand All @@ -62,14 +62,28 @@ describe('HistoryBox', () => {
totalPages={2}
/>
);
expect(screen.getByText('Sent')).toBeInTheDocument();
expect(screen.getByText('Received')).toBeInTheDocument();

const minted = screen.getAllByText('Minted');
const burned = screen.getAllByText('Burned');
expect(screen.getByText(/You sent/i)).toBeInTheDocument();
expect(screen.getByText(/You received/i)).toBeInTheDocument();
expect(screen.getAllByText(/You were burned/i)).toHaveLength(2);
expect(screen.getAllByText(/You minted/i)).toHaveLength(2);
expect(screen.getAllByText(/You were minted/i)).toHaveLength(4);
});

expect(minted.length).toBe(6);
expect(burned.length).toBe(2);
test('displays transactions as `address2`', () => {
renderWithChainProvider(
<HistoryBox
isLoading={false}
address="address2"
currentPage={1}
sendTxs={mockTransactions}
totalPages={2}
/>
);
expect(screen.getByText(/You sent/i)).toBeInTheDocument();
expect(screen.getByText(/You received/i)).toBeInTheDocument();
expect(screen.getAllByText(/You burned/i)).toHaveLength(2);
expect(screen.getAllByText(/You were minted/i)).toHaveLength(2);
expect(screen.getAllByText(/You minted/i)).toHaveLength(4);
});

test('opens modal when clicking on a transaction', () => {
Expand All @@ -83,7 +97,7 @@ describe('HistoryBox', () => {
/>
);

const transactionElement = screen.getByText('Sent').closest('div[role="button"]');
const transactionElement = screen.getByText(/You sent/i).closest('div[role="button"]');

if (transactionElement) {
fireEvent.click(transactionElement);
Expand All @@ -101,16 +115,16 @@ describe('HistoryBox', () => {
totalPages={2}
/>
);
expect(screen.queryByText('-1.00QT TOKEN')).toBeInTheDocument(); // Send
expect(screen.queryByText('+2.00Q TOKEN')).toBeInTheDocument(); // Receive
expect(screen.queryByText('+3.00T TOKEN')).toBeInTheDocument(); // Mint
expect(screen.queryByText('-1.20B TOKEN')).toBeInTheDocument(); // Burn
expect(screen.queryByText('+5.00M TOKEN')).toBeInTheDocument(); // Payout
expect(screen.queryByText('-2.1 TOKEN')).toBeInTheDocument(); // Burn held balance
expect(screen.queryByText('+2.3 TOKEN')).toBeInTheDocument(); // Payout
expect(screen.queryByText('+2.4 TOKEN')).toBeInTheDocument(); // Payout
expect(screen.queryByText('+2.5 TOKEN')).toBeInTheDocument(); // Payout
expect(screen.queryByText('+2.6 TOKEN')).toBeInTheDocument(); // Payout
expect(screen.queryByText('1.00QT TOKEN')).toBeInTheDocument(); // Send
expect(screen.queryByText('2.00Q TOKEN')).toBeInTheDocument(); // Receive
expect(screen.queryByText('3.00T TOKEN')).toBeInTheDocument(); // Mint
expect(screen.queryByText('1.20B TOKEN')).toBeInTheDocument(); // Burn
expect(screen.queryByText('5.00M TOKEN')).toBeInTheDocument(); // Payout
expect(screen.queryByText('2.1 TOKEN')).toBeInTheDocument(); // Burn held balance
expect(screen.queryByText('2.3 TOKEN')).toBeInTheDocument(); // Payout
expect(screen.queryByText('2.4 TOKEN')).toBeInTheDocument(); // Payout
expect(screen.queryByText('2.5 TOKEN')).toBeInTheDocument(); // Payout
expect(screen.queryByText('2.6 TOKEN')).toBeInTheDocument(); // Payout
});

test('displays loading state', () => {
Expand Down
Loading

0 comments on commit d041b41

Please sign in to comment.