2017-10-19 17:07:09 -04:00
|
|
|
/* eslint-env jest */
|
2025-01-27 22:04:43 +02:00
|
|
|
/* eslint-disable no-unused-vars */
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import {render, fireEvent} from '@testing-library/react';
|
|
|
|
import Button from '../../../src/components/button/button.jsx';
|
2017-10-19 17:07:09 -04:00
|
|
|
|
|
|
|
describe('Button', () => {
|
|
|
|
test('triggers callback when clicked', () => {
|
|
|
|
const onClick = jest.fn();
|
2025-01-27 22:04:43 +02:00
|
|
|
const {getByText} = render(
|
2017-10-19 17:07:09 -04:00
|
|
|
<Button onClick={onClick}>
|
|
|
|
{'Button'}
|
|
|
|
</Button>
|
|
|
|
);
|
2025-01-27 22:04:43 +02:00
|
|
|
|
|
|
|
const buttonElement = getByText('Button');
|
|
|
|
fireEvent.click(buttonElement);
|
2017-10-19 17:07:09 -04:00
|
|
|
expect(onClick).toHaveBeenCalled();
|
|
|
|
});
|
2025-01-28 13:55:24 +02:00
|
|
|
});
|