diff --git a/components/top-nav-breadcrumb.tsx b/components/top-nav-breadcrumb.tsx index b35c24e5..6bcb42eb 100644 --- a/components/top-nav-breadcrumb.tsx +++ b/components/top-nav-breadcrumb.tsx @@ -1,7 +1,6 @@ "use client" import * as React from "react" -import Link from "next/link" import { usePathname, useRouter, useSearchParams } from "next/navigation" import { useTranslation } from "react-i18next" import { @@ -99,18 +98,14 @@ export function TopNavBreadcrumb() { {item.href ? ( { - e.preventDefault() - if (item.href) router.push(item.href) - }} - > - {item.label} - - } - /> + href={item.href} + onClick={(e) => { + e.preventDefault() + router.push(item.href!) + }} + > + {item.label} + ) : ( {item.label} )} diff --git a/tests/lib/top-nav-breadcrumb-source.test.js b/tests/lib/top-nav-breadcrumb-source.test.js new file mode 100644 index 00000000..1a4987d6 --- /dev/null +++ b/tests/lib/top-nav-breadcrumb-source.test.js @@ -0,0 +1,13 @@ +import test from "node:test" +import assert from "node:assert/strict" +import fs from "node:fs" + +test("top nav breadcrumb handles clicks on the rendered breadcrumb link", () => { + const source = fs.readFileSync("components/top-nav-breadcrumb.tsx", "utf8") + + assert.equal(source.includes('import Link from "next/link"'), false) + assert.equal(source.includes("