You don't have access to this class

Keep learning! Join and start boosting your career

Aprovecha el precio especial y haz tu profesi贸n a prueba de IA

Antes: $249

Currency
$209
Suscr铆bete

Termina en:

0 D铆as
5 Hrs
16 Min
1 Seg

Button test

5/15
Resources

Contributions 2

Questions 1

Sort by:

Want to see more contributions, questions and answers from the community?

en mi caso, para que todo pueda correr bien y pase el test, a la hora de desestructurar las props a帽adir 鈥therProps

const { className, bgColor, color, width, height, colorHover, bgColorHover, borderRadius, ...otherProps } = props 

el archivo completo quedar铆a de esta forma
src/Button/Button.js:

import { forwardRef } from 'react'
import { cx, css } from "@emotion/css";
import { PropTypes } from 'prop-types'

const buttonStyles = (bgColor, color, width, height, colorHover, bgColorHover, borderRadius)=> css`
    background-color: ${bgColor};
    color: ${color};
    border-radius: ${borderRadius || '8px'};
    width: ${width || '40px'};
    height: ${height || '150px'};
    text-align: center;
    &:hover {
        background-color: ${bgColorHover};
        color: ${colorHover};
    }
`

const Button = forwardRef((props, ref)=> {
    const { className, bgColor, color, width, height, colorHover, bgColorHover, borderRadius, ...otherProps } = props 
    
    return (
        <button
            ref={ref}
            type="button"
            {...otherProps}
            className={cx(buttonStyles(bgColor, color, width, height, colorHover, bgColorHover, borderRadius), className)}
        />
    )
})

Button.propTypes = {
    className: PropTypes.string,
    bgColor: PropTypes.string,
    color: PropTypes.string,
    width: PropTypes.string,
    height: PropTypes.string,
    bgColorHover: PropTypes.string,
    colorHover: PropTypes.string,
    borderRadius: PropTypes.string
}

export default Button 

Agregue la siguiente l铆nea de c贸digo, pues no me reconoc铆a los m茅todos de toHaveClass y toHaveStyle:

import { toHaveClass,toHaveStyle } from '@testing-library/jest-dom';