refactor(frontend): clean up code by consolidating multi-line JSX into single lines where feasible
- Refactored JSX elements to improve readability by collapsing multi-line props and attributes into single lines if their length permits. - Improved consistency in component imports by grouping and consolidating them. - No functional changes, purely restructuring for clarity and maintainability.
This commit is contained in:
@@ -65,38 +65,20 @@ describe('RecentActivity', () => {
|
||||
|
||||
it('shows View All button when there are more activities than maxItems', () => {
|
||||
const onViewAll = jest.fn();
|
||||
render(
|
||||
<RecentActivity
|
||||
activities={mockActivities}
|
||||
maxItems={2}
|
||||
onViewAll={onViewAll}
|
||||
/>
|
||||
);
|
||||
render(<RecentActivity activities={mockActivities} maxItems={2} onViewAll={onViewAll} />);
|
||||
expect(screen.getByRole('button', { name: /view all/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not show View All button when all activities are shown', () => {
|
||||
const onViewAll = jest.fn();
|
||||
render(
|
||||
<RecentActivity
|
||||
activities={mockActivities}
|
||||
maxItems={5}
|
||||
onViewAll={onViewAll}
|
||||
/>
|
||||
);
|
||||
render(<RecentActivity activities={mockActivities} maxItems={5} onViewAll={onViewAll} />);
|
||||
expect(screen.queryByRole('button', { name: /view all/i })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onViewAll when View All button is clicked', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onViewAll = jest.fn();
|
||||
render(
|
||||
<RecentActivity
|
||||
activities={mockActivities}
|
||||
maxItems={2}
|
||||
onViewAll={onViewAll}
|
||||
/>
|
||||
);
|
||||
render(<RecentActivity activities={mockActivities} maxItems={2} onViewAll={onViewAll} />);
|
||||
|
||||
await user.click(screen.getByRole('button', { name: /view all/i }));
|
||||
expect(onViewAll).toHaveBeenCalledTimes(1);
|
||||
@@ -104,24 +86,14 @@ describe('RecentActivity', () => {
|
||||
|
||||
it('shows Review Request button for items requiring action', () => {
|
||||
const onActionClick = jest.fn();
|
||||
render(
|
||||
<RecentActivity
|
||||
activities={mockActivities}
|
||||
onActionClick={onActionClick}
|
||||
/>
|
||||
);
|
||||
render(<RecentActivity activities={mockActivities} onActionClick={onActionClick} />);
|
||||
expect(screen.getByRole('button', { name: /review request/i })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('calls onActionClick when Review Request button is clicked', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onActionClick = jest.fn();
|
||||
render(
|
||||
<RecentActivity
|
||||
activities={mockActivities}
|
||||
onActionClick={onActionClick}
|
||||
/>
|
||||
);
|
||||
render(<RecentActivity activities={mockActivities} onActionClick={onActionClick} />);
|
||||
|
||||
await user.click(screen.getByRole('button', { name: /review request/i }));
|
||||
expect(onActionClick).toHaveBeenCalledWith('act-003');
|
||||
|
||||
Reference in New Issue
Block a user