Skip to content

Commit

Permalink
fix: add forwardRef back to button component
Browse files Browse the repository at this point in the history
  • Loading branch information
matt-cratebind committed Jan 10, 2022
1 parent 375db48 commit a00f0a0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
20 changes: 19 additions & 1 deletion cypress/components/Text.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,23 @@ import { Text } from '../../src/Text';
it('renders children as text', () => {
const text = 'Text';
mount(<Text id="target">{text}</Text>);
cy.get('#target').contains(text);
cy.get('p').contains(text);
});

it('passes styles to <p> element', () => {
const styles = {
color: 'red',
fontSize: '20px',
};

mount(<Text {...styles}>Text</Text>);

cy.get('p').should('have.css', 'color', 'rgb(255, 0, 0)');
cy.get('p').should('have.css', 'font-size', '20px');
});

it('renders different elements with "as" prop', () => {
mount(<Text as="h1">Text</Text>);

cy.get('h1').contains('Text');
});
4 changes: 2 additions & 2 deletions src/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export interface ButtonProps extends MinervaProps, PseudoBoxProps {
// }: ButtonProps,
// forwardedRef
// ) {
export const Button = function Button(
export const Button = React.forwardRef(function Button(
{
children,
disabled = false,
Expand Down Expand Up @@ -146,7 +146,7 @@ export const Button = function Button(
{isLoading ? <Spinner /> : children}
</Box>
);
} as ForwardRefComponent<'button', ButtonProps>;
}) as ForwardRefComponent<'button', ButtonProps>;

export default Button;

Expand Down

0 comments on commit a00f0a0

Please sign in to comment.