2021-02-04 19:15:23 +01:00
|
|
|
import React from 'react';
|
2022-09-23 16:41:35 +02:00
|
|
|
import { fireEvent } from '@testing-library/react';
|
|
|
|
import { renderWithProvider } from '../../../../test/lib/render-helpers';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-03-16 22:00:08 +01:00
|
|
|
import InfoBox from './info-box.component';
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2021-04-15 20:01:46 +02:00
|
|
|
describe('InfoBox', () => {
|
2020-01-30 20:34:45 +01:00
|
|
|
const props = {
|
|
|
|
title: 'Title',
|
|
|
|
description: 'Description',
|
2022-09-23 16:41:35 +02:00
|
|
|
onClose: jest.fn(),
|
2021-02-04 19:15:23 +01:00
|
|
|
};
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-09-23 16:41:35 +02:00
|
|
|
it('should match snapshot', () => {
|
|
|
|
const { container } = renderWithProvider(<InfoBox {...props} />);
|
|
|
|
expect(container).toMatchSnapshot();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-09-23 16:41:35 +02:00
|
|
|
it('should call handleClose on info close element', () => {
|
|
|
|
const { queryByTestId } = renderWithProvider(<InfoBox {...props} />);
|
|
|
|
const infoBoxClose = queryByTestId('info-box-close');
|
2020-01-30 20:34:45 +01:00
|
|
|
|
2022-09-23 16:41:35 +02:00
|
|
|
fireEvent.click(infoBoxClose);
|
|
|
|
expect(props.onClose).toHaveBeenCalled();
|
2021-02-04 19:15:23 +01:00
|
|
|
});
|
|
|
|
});
|