diff --git a/src/components/FunctionalArea/TopBar/TopBar.component.test.tsx b/src/components/FunctionalArea/TopBar/TopBar.component.test.tsx index e6e44ac13532f839d4b82fbde10dfdd537fc49ce..ae9f17c99c9042ec6c43ad19c455f335e7071b19 100644 --- a/src/components/FunctionalArea/TopBar/TopBar.component.test.tsx +++ b/src/components/FunctionalArea/TopBar/TopBar.component.test.tsx @@ -1,10 +1,14 @@ import { StoreType } from '@/redux/store'; -import { getReduxWrapperWithStore } from '@/utils/testing/getReduxWrapperWithStore'; +import { + InitialStoreState, + getReduxWrapperWithStore, +} from '@/utils/testing/getReduxWrapperWithStore'; import { render, screen } from '@testing-library/react'; +import { initialStateFixture } from '@/redux/drawer/drawerFixture'; import { TopBar } from './TopBar.component'; -const renderComponent = (): { store: StoreType } => { - const { Wrapper, store } = getReduxWrapperWithStore(); +const renderComponent = (initialStoreState: InitialStoreState = {}): { store: StoreType } => { + const { Wrapper, store } = getReduxWrapperWithStore(initialStoreState); return ( render( @@ -25,4 +29,16 @@ describe('TopBar - component', () => { expect(screen.getByTestId('user-avatar')).toBeInTheDocument(); expect(screen.getByTestId('search-bar')).toBeInTheDocument(); }); + + it('should open submaps drawer on submaps button click', () => { + const { store } = renderComponent({ drawer: initialStateFixture }); + + const button = screen.getByRole('button', { name: 'Submaps' }); + button.click(); + + const { isOpen, drawerName } = store.getState().drawer; + + expect(isOpen).toBe(true); + expect(drawerName).toBe('submaps'); + }); });