We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6da5041 + 91fecf4 commit 63c8b9dCopy full SHA for 63c8b9d
src/App.test.js
src/components/Button/button.test.tsx
@@ -0,0 +1,17 @@
1
+import { fireEvent, render, screen } from '@testing-library/react';
2
+import React from 'react';
3
+import Button from './Button';
4
+
5
+test('calls onClick prop when clicked', () => {
6
+ const handleClick = jest.fn();
7
+ render(<Button onClick={handleClick} label='Click me' />);
8
+ fireEvent.click(screen.getByText(/click me/i));
9
+ expect(handleClick).toHaveBeenCalledTimes(1);
10
+});
11
12
+test('should not call onClick prop when button is disabled', () => {
13
14
+ render(<Button onClick={handleClick} label='Click me' disabled={true} />);
15
16
+ expect(handleClick).toHaveBeenCalledTimes(0);
17
0 commit comments