feat: adiciona test-ids em menu lateral

This commit is contained in:
marlon passos 2023-03-29 09:46:12 -03:00
parent d727fdb369
commit 80fda5ebe2
2 changed files with 14 additions and 2 deletions

View File

@ -4,7 +4,7 @@ import { NavLink, NavLinkProps } from "react-router-dom";
interface LiProps extends NavLinkProps {
text: string;
to: NavLinkProps["to"];
to: string;
}
const LiForm = (props: LiProps) => {
@ -12,6 +12,7 @@ const LiForm = (props: LiProps) => {
return (
<li>
<NavLink
data-testid={geDataTestId(to)}
to={to}
className={({ isActive }) =>
isActive
@ -25,4 +26,12 @@ const LiForm = (props: LiProps) => {
);
};
function geDataTestId(url: string ) {
return "lateralMenu__item" + (isCurrentUrl()) ? "lateralMenu__itemActive" : "";
function isCurrentUrl() {
return window.location.href.includes(url);
}
}
export { LiForm };

View File

@ -10,7 +10,10 @@ const Nav = () => {
return (
<>
<nav className={styles["page-subject__nav"]}>
<nav
className={styles["page-subject__nav"]}
data-testid="lateralMenu__container"
>
<ul className={styles["page-subject__menu"]}>
<LiForm to="/" text="Sobre" />
<LiForm to="/forma-de-pagamento" text="Forma de Pagamento" />