diff --git a/src/common/header/__tests__/Header.test.tsx b/src/common/header/__tests__/Header.test.tsx
index 9002ce18..a2169c25 100644
--- a/src/common/header/__tests__/Header.test.tsx
+++ b/src/common/header/__tests__/Header.test.tsx
@@ -1,32 +1,32 @@
import React from 'react';
-import { mount } from 'enzyme';
+import { render, fireEvent, waitFor } from '@testing-library/react';
import i18n from '../../test/testi18nInit';
import Header from '../Header';
-const getWrapper = () => mount();
-
-it('language is changed from header language selector', () => {
+it('language is changed from header language selector', async () => {
i18n.changeLanguage('fi');
- const wrapper = getWrapper();
+ const { getByText } = render();
const ariaCurrent = 'aria-current';
- const fiButton = wrapper
- .find('button')
- .filterWhere(node => node.text() === 'Suomi');
- expect(fiButton.props()[ariaCurrent]).toBe(true);
+ // Find the button for Finnish
+ const fiButton = getByText('Suomi').parentElement;
+ expect(fiButton?.getAttribute(ariaCurrent)).toBe('true');
expect(i18n.language).toBe('fi');
- const svButton = wrapper
- .find('button')
- .filterWhere(node => node.text() === 'Svenska');
- expect(svButton.props()[ariaCurrent]).toBe(false);
+ // Find the button for Swedish
+ const svButton = getByText('Svenska').parentElement;
+ expect(svButton?.getAttribute(ariaCurrent)).toBe('false');
+
// Change the language
- svButton.simulate('click');
+ if (svButton) {
+ fireEvent.click(svButton);
+ }
- setTimeout(() => {
- expect(fiButton.props()[ariaCurrent]).toBe(false);
+ await waitFor(() => {
+ expect(fiButton?.getAttribute(ariaCurrent)).toBe('false');
+ expect(svButton?.getAttribute(ariaCurrent)).toBe('true');
expect(i18n.language).toBe('sv');
- }, 100);
+ });
});