Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function HtmlNavbarItem({
mobile = false,
isDropdownItem = false,
}: Props): ReactNode {
const Comp = isDropdownItem ? 'li' : 'div';
const Comp = mobile || isDropdownItem ? 'li' : 'div';
return (
<Comp
className={clsx(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// @vitest-environment jsdom

import {describe, expect, it} from 'vitest';
import {render} from '@testing-library/react';
import '@testing-library/jest-dom/vitest';

import HtmlNavbarItem from '../HtmlNavbarItem';

describe('HtmlNavbarItem', () => {
it('renders a li element on mobile', () => {
const {container} = render(<HtmlNavbarItem value="Example" mobile />);

expect(container.firstElementChild?.tagName).toBe('LI');
});

it('renders a div element on desktop', () => {
const {container} = render(<HtmlNavbarItem value="Example" />);

expect(container.firstElementChild?.tagName).toBe('DIV');
});

it('renders a li element for dropdown items', () => {
const {container} = render(
<HtmlNavbarItem value="Example" isDropdownItem />,
);

expect(container.firstElementChild?.tagName).toBe('LI');
});
});