Download client/src/components/Input/Generations/__tests__/Button.spec.tsx from Zhitomir/chat: direct link, hf CLI and curl.
- Browser
- Download file 820 Bytes
-
https://huggingface.co/spaces/Zhitomir/chat/resolve/main/client/src/components/Input/Generations/__tests__/Button.spec.tsx
- Command line
-
hf download hf://spaces/Zhitomir/chat/client/src/components/Input/Generations/__tests__/Button.spec.tsx
-
curl -L -o Button.spec.tsx https://huggingface.co/spaces/Zhitomir/chat/resolve/main/client/src/components/Input/Generations/__tests__/Button.spec.tsx
820 Bytes
| import { render, fireEvent } from '@testing-library/react'; | |
| import Button from '../Button'; | |
| describe('Button', () => { | |
| it('renders with the correct type and children', () => { | |
| const { getByTestId, getByText } = render( | |
| <Button | |
| type="regenerate" | |
| onClick={() => { | |
| (''); | |
| }} | |
| > | |
| Regenerate | |
| </Button>, | |
| ); | |
| expect(getByTestId('regenerate-generation-button')).toBeInTheDocument(); | |
| expect(getByText('Regenerate')).toBeInTheDocument(); | |
| }); | |
| it('calls onClick when clicked', () => { | |
| const handleClick = jest.fn(); | |
| const { getByText } = render( | |
| <Button type="continue" onClick={handleClick}> | |
| Continue | |
| </Button>, | |
| ); | |
| fireEvent.click(getByText('Continue')); | |
| expect(handleClick).toHaveBeenCalledTimes(1); | |
| }); | |
| }); | |