Skip to content

Commit

Permalink
Add test for language select
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Burmatov <[email protected]>
  • Loading branch information
Future998 committed Dec 4, 2024
1 parent 079010c commit 384723a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/__tests__/Header/Header.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { render, screen } from '@testing-library/react';
import Header from 'components/Header/Header';
import React from 'react';
import MockThemeProvider from '__mocks__/MockThemeProvider';
import { BrowserRouter, Route, Routes } from 'react-router-dom';

jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useNavigate: () => {}
}));

const HeaderWrapper = () => {
return (
<MockThemeProvider>
<BrowserRouter>
<Routes>
<Route path="*" element={<Header />} />
</Routes>
</BrowserRouter>
</MockThemeProvider>
);
};

describe('Account Menu', () => {
it('is language select renders in header component', async () => {
render(<HeaderWrapper />);
expect(await screen.queryByTestId('select-language')).toBeInTheDocument();
});
});
1 change: 1 addition & 0 deletions src/components/Header/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ function Header({ setSearchCurrentValue = () => {} }) {
value={selectedLanguage}
onChange={handleLanguageChange}
MenuProps={{ disableScrollLock: true }}
data-testid="select-language"
>
{Object.keys(locales).map((locale) => (
<MenuItem key={locale} value={locale}>
Expand Down

0 comments on commit 384723a

Please sign in to comment.