Skip to content

Commit

Permalink
Write first test
Browse files Browse the repository at this point in the history
  • Loading branch information
jessepinho committed Jul 16, 2024
1 parent 5b6251c commit 8d51c38
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/ui/src/Button/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { describe, expect, it, vi } from 'vitest';
import { Button } from '.';
import { fireEvent, render } from '@testing-library/react';
import { ThemeProvider } from '../ThemeProvider';

describe('<Button />', () => {
it('calls the passed-in click handler when clicked', () => {
const onClick = vi.fn();
const { getByText } = render(<Button onClick={onClick}>Click me</Button>, {
wrapper: ThemeProvider,
});

fireEvent.click(getByText('Click me'));

expect(onClick).toHaveBeenCalledOnce();
});
});

0 comments on commit 8d51c38

Please sign in to comment.