feat: adiciona test-ids em menu lateral
This commit is contained in:
parent
d727fdb369
commit
80fda5ebe2
@ -4,7 +4,7 @@ import { NavLink, NavLinkProps } from "react-router-dom";
|
|||||||
|
|
||||||
interface LiProps extends NavLinkProps {
|
interface LiProps extends NavLinkProps {
|
||||||
text: string;
|
text: string;
|
||||||
to: NavLinkProps["to"];
|
to: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const LiForm = (props: LiProps) => {
|
const LiForm = (props: LiProps) => {
|
||||||
@ -12,6 +12,7 @@ const LiForm = (props: LiProps) => {
|
|||||||
return (
|
return (
|
||||||
<li>
|
<li>
|
||||||
<NavLink
|
<NavLink
|
||||||
|
data-testid={geDataTestId(to)}
|
||||||
to={to}
|
to={to}
|
||||||
className={({ isActive }) =>
|
className={({ isActive }) =>
|
||||||
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 };
|
export { LiForm };
|
||||||
|
@ -10,7 +10,10 @@ const Nav = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<nav className={styles["page-subject__nav"]}>
|
<nav
|
||||||
|
className={styles["page-subject__nav"]}
|
||||||
|
data-testid="lateralMenu__container"
|
||||||
|
>
|
||||||
<ul className={styles["page-subject__menu"]}>
|
<ul className={styles["page-subject__menu"]}>
|
||||||
<LiForm to="/" text="Sobre" />
|
<LiForm to="/" text="Sobre" />
|
||||||
<LiForm to="/forma-de-pagamento" text="Forma de Pagamento" />
|
<LiForm to="/forma-de-pagamento" text="Forma de Pagamento" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user