Skip to content

Commit

Permalink
Merge pull request #609 from juntossomosmais/feat/add-button-type-in-…
Browse files Browse the repository at this point in the history
…ts-props

feat(react-ds): add type props in ts
  • Loading branch information
RodrigoRVSN authored Jan 30, 2023
2 parents dd10c48 + 851f809 commit 81ed49e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/react-ds/src/components/Button/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,18 @@ describe('<Button />', () => {
fireEvent.click(getByText('Loading'))
expect(onClick).not.toBeCalled()
})

it('should be able to submit a form with type submit', () => {
const submitMocked = jest.fn()

const { getByText } = render(
<form onSubmit={submitMocked}>
<Button type="submit">Submit</Button>
</form>
)

fireEvent.submit(getByText('Submit'))

expect(submitMocked).toHaveBeenCalled()
})
})
4 changes: 3 additions & 1 deletion packages/react-ds/src/components/Button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import styles from '@venice/styles/components/Button.module.scss'

import { Spinner } from '../Spinner'

export interface IButtonProps extends Omit<IButton, 'color'> {
export interface IButtonProps
extends Omit<IButton, 'color'>,
React.ButtonHTMLAttributes<HTMLButtonElement> {
/** string */
className?: string
/** 'default' | 'primary' | 'secondary' | 'white' */
Expand Down

0 comments on commit 81ed49e

Please sign in to comment.