Skip to content

Commit

Permalink
update test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdi-torabiv committed Aug 30, 2024
1 parent 1d5f88d commit fc50ebf
Showing 1 changed file with 8 additions and 19 deletions.
27 changes: 8 additions & 19 deletions src/components/layouts/AppbarApp.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
import { render, screen, fireEvent } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import { describe, it, expect, vi } from 'vitest';
import { IconButton, Avatar } from '@mui/material';
import AppbarApp from './AppbarApp';

vi.mock('./AccountPopover', () => ({
default: () => (
<div>
<IconButton data-testid="account-popover-button">
<Avatar />
</IconButton>
<div data-testid="account-popover">AccountPopover</div>
</div>
// Mocking the ConnectButton from RainbowKit
vi.mock('@rainbow-me/rainbowkit', () => ({
ConnectButton: () => (
<div data-testid="connect-button">Mocked ConnectButton</div>
),
}));

Expand All @@ -20,18 +15,12 @@ describe('AppbarApp', () => {

const appBar = screen.getByTestId('Appbar');
expect(appBar).toBeInTheDocument();

const accountPopover = screen.getByTestId('account-popover');
expect(accountPopover).toBeInTheDocument();
});

it('should open AccountPopover on icon button click', () => {
it('should render the ConnectButton', () => {
render(<AppbarApp />);

const iconButton = screen.getByTestId('account-popover-button');
fireEvent.click(iconButton);

const accountPopover = screen.getByTestId('account-popover');
expect(accountPopover).toBeVisible();
const connectButton = screen.getByTestId('connect-button');
expect(connectButton).toBeInTheDocument();
});
});

0 comments on commit fc50ebf

Please sign in to comment.