Skip to content

Commit

Permalink
refactor(testing): DISCOVERY-523 Other review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mirekdlugosz committed Sep 25, 2024
1 parent 5baf67b commit 979fe38
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -39,7 +39,7 @@ describe('SimpleDropdown', () => {
dropdownItems: [
{ item: 'dolor', ouiaId: 'ouia-dolor' },
{ item: 'sit', ouiaId: 'ouia-sit' }
] as SimpleDropdownItemProps[]
]
};

const { asFragment } = render(<SimpleDropdown {...props} />);
Expand All @@ -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(<SimpleDropdown {...props} />);
Expand Down
8 changes: 3 additions & 5 deletions src/components/simpleDropdown/simpleDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ const SimpleDropdown: React.FC<SimpleDropdownProps> = ({
variant={variant}
aria-label={ariaLabel}
isDisabled={!dropdownItems || dropdownItems.length === 0}
{...(menuToggleOuiaId && {
'data-ouia-component-id': menuToggleOuiaId
})}
data-ouia-component-id={menuToggleOuiaId}
>
{label}
</MenuToggle>
Expand All @@ -68,7 +66,7 @@ const SimpleDropdown: React.FC<SimpleDropdownProps> = ({
<DropdownList>
{Array.isArray(dropdownItems) &&
dropdownItems.map(({ item, ouiaId }) => (
<DropdownItem key={item} onClick={() => onSelect(item)} {...(ouiaId && { ouiaId: ouiaId })}>
<DropdownItem key={item} onClick={() => onSelect(item)} ouiaId={ouiaId}>
{item}
</DropdownItem>
))}
Expand All @@ -77,4 +75,4 @@ const SimpleDropdown: React.FC<SimpleDropdownProps> = ({
);
};

export { SimpleDropdown as default, SimpleDropdown, type SimpleDropdownProps, type SimpleDropdownItemProps };
export { SimpleDropdown as default, SimpleDropdown, type SimpleDropdownProps };
2 changes: 1 addition & 1 deletion src/components/typeAheadCheckboxes/typeaheadCheckboxes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ const TypeaheadCheckboxes: React.FC<TypeaheadCheckboxesProps> = ({
innerRef={toggleRef}
isExpanded={isOpen}
isFullWidth
{...(menuToggleOuiaId && { 'data-ouia-component-id': menuToggleOuiaId })}
data-ouia-component-id={menuToggleOuiaId}
>
<TextInputGroup isPlain>
<TextInputGroupMain
Expand Down

0 comments on commit 979fe38

Please sign in to comment.