diff --git a/src/old/lib/components/FiltersButton/__test__/FilterButton.test.tsx b/src/old/lib/components/FiltersButton/__test__/FilterButton.test.tsx new file mode 100644 index 000000000..350cb31a7 --- /dev/null +++ b/src/old/lib/components/FiltersButton/__test__/FilterButton.test.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import { render, screen, fireEvent } from '@testing-library/react'; +import FilterButton from '../FiltersButton'; + +const setFilterMenuOpenMock = jest.fn(); + +describe('Filter button', () => { + it('should render button for opening filters menu', () => { + render( + , + ); + expect(screen.getByText('Фільтри')).toBeInTheDocument(); + }); + + it('should render button for closing filters menu', () => { + const { container } = render( + , + ); + const closeIcon = container.querySelector('svg'); + expect(closeIcon).toBeInTheDocument(); + }); + + it('button should call handler function by click', () => { + render( + , + ); + const button = screen.getByRole('button'); + fireEvent.click(button); + expect(setFilterMenuOpenMock).toHaveBeenCalled(); + }); +});