From b1c283a110bbd2badd8cc8ff15df7bb8d86eb85c Mon Sep 17 00:00:00 2001 From: Camilla Marie Dalan Date: Wed, 27 Nov 2024 14:34:12 +0100 Subject: [PATCH] fixes textareacomponent jest test --- src/layout/TextArea/TextAreaComponent.test.tsx | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/layout/TextArea/TextAreaComponent.test.tsx b/src/layout/TextArea/TextAreaComponent.test.tsx index 41a332e15e..dcb0cdc4d0 100644 --- a/src/layout/TextArea/TextAreaComponent.test.tsx +++ b/src/layout/TextArea/TextAreaComponent.test.tsx @@ -4,7 +4,6 @@ import { screen } from '@testing-library/react'; import { userEvent } from '@testing-library/user-event'; import { defaultDataTypeMock } from 'src/__mocks__/getLayoutSetsMock'; -import { getDescriptionId } from 'src/components/label/Label'; import { TextAreaComponent } from 'src/layout/TextArea/TextAreaComponent'; import { renderGenericComponentTest } from 'src/test/renderWithProviders'; import type { RenderGenericComponentTestProps } from 'src/test/renderWithProviders'; @@ -66,16 +65,15 @@ describe('TextAreaComponent', () => { expect(formDataMethods.setLeafValue).not.toHaveBeenCalled(); }); - it('should have aria-describedby attribute if textResourceBindings.description is present', async () => { + it('should have aria-describedby attribute if title and description is present', async () => { await render({ component: { id: 'id', - textResourceBindings: { description: 'tekst' }, + textResourceBindings: { title: 'tittel', description: 'beskrivelse' }, }, }); - const textarea = screen.getByRole('textbox'); - expect(textarea.getAttribute('aria-describedby')).toContain(getDescriptionId('id')); + expect(screen.getByRole('textbox', { description: 'beskrivelse' })).toBeInTheDocument(); }); it('should not have aria-describedby attribute if textResourceBindings is present without description', async () => {