generated from Real-Dev-Squad/website-template
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into dependabot/npm_and_yarn/postcss-8.4.31
- Loading branch information
Showing
7 changed files
with
81 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import { Button } from '@/components/Button'; | ||
Button; | ||
|
||
describe('Button', () => { | ||
it('should render Button', () => { | ||
const handleOnClickMock = jest.fn(); | ||
const { getByRole } = render( | ||
<Button | ||
type="button" | ||
className="w-full md:w-auto bg-gray-200 px-4 md:px-8 py-3 hover:bg-gray-300 mt-2 md:mt-0 md:rounded-none" | ||
onClick={handleOnClickMock} | ||
> | ||
Generate | ||
</Button> | ||
); | ||
const buttonElement = getByRole('button'); | ||
expect(buttonElement).toHaveAttribute('type', 'button'); | ||
expect(buttonElement).toHaveTextContent('Generate'); | ||
}); | ||
|
||
test('should render button with the type submit', () => { | ||
const handleOnClickMock = jest.fn(); | ||
const { getByRole } = render( | ||
<Button | ||
type="submit" | ||
className="w-full md:w-auto bg-gray-200 px-4 md:px-8 py-3 hover:bg-gray-300 mt-2 md:mt-0 md:rounded-none" | ||
onClick={handleOnClickMock} | ||
> | ||
Log in | ||
</Button> | ||
); | ||
|
||
const buttonElement = getByRole('button'); | ||
expect(buttonElement).toHaveAttribute('type', 'submit'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
|
||
interface ButtonProps { | ||
type?: 'button' | 'submit' | 'reset'; | ||
className: string; | ||
onClick: (event: React.MouseEvent<HTMLButtonElement>) => void; | ||
children: React.ReactNode; | ||
disabled?: boolean; | ||
} | ||
|
||
const Button: React.FC<ButtonProps> = ({ type, className, onClick, children, disabled }) => { | ||
return ( | ||
<button type={type} className={className} onClick={onClick} disabled={disabled}> | ||
{children} | ||
</button> | ||
); | ||
}; | ||
|
||
Button.defaultProps = { | ||
type: 'button', | ||
className: 'w-full bg-gray-200 hover:bg-gray-300 ', | ||
}; | ||
|
||
export { Button }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters