Skip to content

Commit

Permalink
fixes textareacomponent jest test
Browse files Browse the repository at this point in the history
  • Loading branch information
cammiida committed Nov 27, 2024
1 parent 9b392e3 commit b1c283a
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/layout/TextArea/TextAreaComponent.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 () => {
Expand Down

0 comments on commit b1c283a

Please sign in to comment.