From 979fe3812afac4434e397acb3cc584e40da9debc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mirek=20D=C5=82ugosz?= Date: Wed, 25 Sep 2024 12:19:08 +0200 Subject: [PATCH] refactor(testing): DISCOVERY-523 Other review fixes --- .../simpleDropdown/__tests__/simpleDropdown.test.tsx | 6 +++--- src/components/simpleDropdown/simpleDropdown.tsx | 8 +++----- .../typeAheadCheckboxes/typeaheadCheckboxes.tsx | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/components/simpleDropdown/__tests__/simpleDropdown.test.tsx b/src/components/simpleDropdown/__tests__/simpleDropdown.test.tsx index 8095f5c1..86190f46 100644 --- a/src/components/simpleDropdown/__tests__/simpleDropdown.test.tsx +++ b/src/components/simpleDropdown/__tests__/simpleDropdown.test.tsx @@ -2,7 +2,7 @@ import React from 'react'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { shallowComponent } from '../../../../config/jest.setupTests'; -import { SimpleDropdown, SimpleDropdownItemProps } from '../simpleDropdown'; +import { SimpleDropdown } from '../simpleDropdown'; describe('SimpleDropdown', () => { it('should render a basic component', async () => { @@ -39,7 +39,7 @@ describe('SimpleDropdown', () => { dropdownItems: [ { item: 'dolor', ouiaId: 'ouia-dolor' }, { item: 'sit', ouiaId: 'ouia-sit' } - ] as SimpleDropdownItemProps[] + ] }; const { asFragment } = render(); @@ -55,7 +55,7 @@ describe('SimpleDropdown', () => { const props = { label: 'Lorem ipsum', onSelect: onMockSelect, - dropdownItems: [{ item: 'dolor' }, { item: 'sit' }] as SimpleDropdownItemProps[] + dropdownItems: [{ item: 'dolor' }, { item: 'sit' }] }; const { asFragment } = render(); diff --git a/src/components/simpleDropdown/simpleDropdown.tsx b/src/components/simpleDropdown/simpleDropdown.tsx index 5ad43358..82f4744c 100644 --- a/src/components/simpleDropdown/simpleDropdown.tsx +++ b/src/components/simpleDropdown/simpleDropdown.tsx @@ -57,9 +57,7 @@ const SimpleDropdown: React.FC = ({ variant={variant} aria-label={ariaLabel} isDisabled={!dropdownItems || dropdownItems.length === 0} - {...(menuToggleOuiaId && { - 'data-ouia-component-id': menuToggleOuiaId - })} + data-ouia-component-id={menuToggleOuiaId} > {label} @@ -68,7 +66,7 @@ const SimpleDropdown: React.FC = ({ {Array.isArray(dropdownItems) && dropdownItems.map(({ item, ouiaId }) => ( - onSelect(item)} {...(ouiaId && { ouiaId: ouiaId })}> + onSelect(item)} ouiaId={ouiaId}> {item} ))} @@ -77,4 +75,4 @@ const SimpleDropdown: React.FC = ({ ); }; -export { SimpleDropdown as default, SimpleDropdown, type SimpleDropdownProps, type SimpleDropdownItemProps }; +export { SimpleDropdown as default, SimpleDropdown, type SimpleDropdownProps }; diff --git a/src/components/typeAheadCheckboxes/typeaheadCheckboxes.tsx b/src/components/typeAheadCheckboxes/typeaheadCheckboxes.tsx index fa1d4c62..5d7651bc 100644 --- a/src/components/typeAheadCheckboxes/typeaheadCheckboxes.tsx +++ b/src/components/typeAheadCheckboxes/typeaheadCheckboxes.tsx @@ -164,7 +164,7 @@ const TypeaheadCheckboxes: React.FC = ({ innerRef={toggleRef} isExpanded={isOpen} isFullWidth - {...(menuToggleOuiaId && { 'data-ouia-component-id': menuToggleOuiaId })} + data-ouia-component-id={menuToggleOuiaId} >