Skip to content

Commit

Permalink
Merge pull request #891 from equinor/fix/add-id-for-sidebar-menuitems
Browse files Browse the repository at this point in the history
  • Loading branch information
mariush2 authored Dec 3, 2024
2 parents 84d6696 + ecf0c11 commit 9732b74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/organisms/SideBar/MenuItem.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,17 @@ describe('MenuItem', () => {
expect(icon).toHaveAttribute('width', '24px');
};

test('should have ID if provided', () => {
const props = fakeProps();
const fakeId = faker.animal.cat();
render(<MenuItem {...props} id={fakeId} replace />, {
wrapper: wrapper,
});

const item = screen.getByTestId('sidebar-menu-item');
expect(item).toHaveAttribute('id', fakeId);
});

test('should navigate if replace is set to true and url is a partial match', () => {
const props = fakeProps();
render(<MenuItem {...props} replace />, {
Expand Down
3 changes: 3 additions & 0 deletions src/organisms/SideBar/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const MenuItem = forwardRef<HTMLAnchorElement, MenuItemProps>(
onClick,
disabled = false,
replace = false,
...props
},
ref
) => {
Expand Down Expand Up @@ -63,6 +64,7 @@ export const MenuItem = forwardRef<HTMLAnchorElement, MenuItemProps>(
ref={ref}
data-testid="sidebar-menu-item"
replace={replace}
{...props}
>
<IconContainer data-testid="icon-container">
<Icon data={icon} size={24} />
Expand Down Expand Up @@ -90,6 +92,7 @@ export const MenuItem = forwardRef<HTMLAnchorElement, MenuItemProps>(
$open={isOpen}
tabIndex={0}
ref={ref}
{...props}
data-testid="sidebar-menu-item"
>
<IconContainer data-testid="icon-container">
Expand Down

0 comments on commit 9732b74

Please sign in to comment.