feat: adiciona test id de parte do footer bottom e refatora um pouco do codigo

This commit is contained in:
marlon passos 2023-03-29 13:25:47 -03:00
parent de0d9b44df
commit 1ca4446fa2
5 changed files with 66 additions and 30 deletions

View File

@ -8,15 +8,10 @@ const FooterBottom = () => {
return ( return (
<section <section
className={styles["page-footer__footer-bottom"]} className={styles["page-footer__footer-bottom"]}
data-testid="footer__bottom" data-testid="footer__bottomContainer"
> >
<div className={styles["page-footer__footer-bottom-container"]}> <div className={styles["page-footer__footer-bottom-container"]}>
<section className={styles["page-footer__container-footer-text"]}> <Copyright />
<Text
className={styles["page-footer__footer-text"]}
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tecmpor"
/>
</section>
<Imgs /> <Imgs />
<Autores /> <Autores />
</div> </div>
@ -25,3 +20,14 @@ const FooterBottom = () => {
}; };
export { FooterBottom }; export { FooterBottom };
export const Copyright = () => (
<section
className={styles["page-footer__container-footer-text"]}>
<Text
testId="footer__copyright"
className={styles["page-footer__footer-text"]}
text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tecmpor"
/>
</section>
)

View File

@ -1,14 +1,19 @@
import React from "react"; import React from "react";
interface ButtonProps { export interface ImgProps {
img: string; img: string;
text: string; text: string;
className: string; className: string;
testId?: string
} }
const Img = (props: ButtonProps) => { const Img = ({ img, text, testId, className }: ImgProps) => (
const { img, text, className } = props; <img
return <img className={className} src={img} alt={text} />; className={className}
}; src={img}
alt={text}
data-testid={testId}
/>
)
export { Img }; export { Img };

View File

@ -1,7 +1,7 @@
import React from "react"; import React from "react";
import styles from "../../footer.module.scss"; import styles from "../../footer.module.scss";
import { Img } from "../img-footer/img"; import { Img, ImgProps } from "../img-footer/img";
import Master from "../assets/img/Master.png"; import Master from "../assets/img/Master.png";
import Visa from "../assets/img/Visa.png"; import Visa from "../assets/img/Visa.png";
import Diners from "../assets/img/Diners.png"; import Diners from "../assets/img/Diners.png";
@ -11,24 +11,46 @@ import Pagseguro from "../assets/img/Pagseguro.png";
import Boleto from "../assets/img/Boleto.png"; import Boleto from "../assets/img/Boleto.png";
import vtex from "../assets/img/vtex-pci-200.png"; import vtex from "../assets/img/vtex-pci-200.png";
const Imgs = () => { const PaymentsMethods = () => {
return ( return (
<section className={styles["page-footer__imgs"]}> <section
<Img className={styles["img"]} img={Master} text="Cartão master" /> className={styles["page-footer__imgs"]}
<Img className={styles["img"]} img={Visa} text="Cartão visa" /> data-testid="footer__paymentMethods"
>
<PaymentMethod img={Master} text="Cartão master" />
<PaymentMethod img={Visa} text="Cartão visa" />
<Img <Img
className={styles["img"]} className={styles["img"]}
img={Diners} img={Diners}
text="Cartão american diners" text="Cartão american diners"
/> />
<Img className={styles["img"]} img={Elo} text="Cartão elo" /> <PaymentMethod img={Elo} text="Cartão elo" />
<Img className={styles["img"]} img={Hiper} text="Cartão hiper" /> <PaymentMethod img={Hiper} text="Cartão hiper" />
<Img className={styles["img"]} img={Pagseguro} text="Pague Seguro" /> <PaymentMethod img={Pagseguro} text="Pague Seguro" />
<Img className={styles["img"]} img={Boleto} text="Pagamento boleto" /> <PaymentMethod img={Boleto} text="Pagamento boleto" />
<div className={styles["divisor"]}></div> <div className={styles["divisor"]}></div>
<Img className={styles["img-grande"]} img={vtex} text="Vtex" /> <PaymentMethod isBig img={vtex} text="Vtex" />
</section> </section>
); );
}; };
export { Imgs }; export type PaymentMethodProps = Pick<ImgProps, "img" | "text"> & {
isBig?: boolean;
}
export const PaymentMethod = ({ img, text, isBig }: PaymentMethodProps) => {
return (
<Img
className={getClassName()}
img={img}
text={text}
testId="footer__paymentMethod"
/>
)
function getClassName() {
return isBig ? styles["img-grande"] : styles["img"]
}
}
export { PaymentsMethods as Imgs };

View File

@ -34,7 +34,7 @@ const Newsletter = () => {
<div className={styles["page-footer__newsletter-form"]}> <div className={styles["page-footer__newsletter-form"]}>
<Field <Field
name="email" name="email"
test-testid="newsletter__input" data-testid="newsletter__input"
className={styles["input"]} className={styles["input"]}
placeholder="E-mail" placeholder="E-mail"
/> />

View File

@ -1,13 +1,16 @@
import React from "react";
interface TextProps { interface TextProps {
text: string; text: string;
className: string; className: string;
testId?: string;
} }
const Text = (props: TextProps) => { const Text = ({ text, className, testId}: TextProps) => (
const { text, className } = props; <p
return <p className={className}>{text}</p>; className={className}
}; data-tesid={testId}
>
{text}
</p>
);
export { Text }; export { Text };