diff --git a/packages/react/src/components/StructuredList/StructuredList-test.js b/packages/react/src/components/StructuredList/__tabs__/StructuredList-test.js similarity index 96% rename from packages/react/src/components/StructuredList/StructuredList-test.js rename to packages/react/src/components/StructuredList/__tabs__/StructuredList-test.js index 3a9a664e492b..55dca7609ed7 100644 --- a/packages/react/src/components/StructuredList/StructuredList-test.js +++ b/packages/react/src/components/StructuredList/__tabs__/StructuredList-test.js @@ -15,7 +15,7 @@ import { StructuredListRow, StructuredListInput, StructuredListCell, -} from '@carbon/react'; +} from '../StructuredList'; import { CheckmarkFilled } from '@carbon/react/icons'; const prefix = 'cds'; @@ -71,9 +71,12 @@ const renderComponent = ({ ...rest } = {}) => { ); }; -const structuredListBodyRowGenerator = (numRows, rest) => { +const structuredListBodyRowGenerator = (numRows, rest, selection) => { return Array.apply(null, Array(numRows)).map((n, i) => ( - + Row {i} Row {i}, Col 2 @@ -102,7 +105,7 @@ const structuredListBodyRowGenerator = (numRows, rest) => { }; const renderSelectionVariant = ({ ...rest } = {}) => { - const { inputProps, wrapperProps } = rest; + const { inputProps, wrapperProps, rowSelection } = rest; return render( @@ -114,7 +117,7 @@ const renderSelectionVariant = ({ ...rest } = {}) => { - {structuredListBodyRowGenerator(4, inputProps)} + {structuredListBodyRowGenerator(4, inputProps, rowSelection)} ); @@ -238,6 +241,12 @@ describe('StructuredList', () => { await user.keyboard('[ArrowDown]'); expect(onKeyDownHandlerFn).toHaveBeenCalledTimes(3); }); + + it('should be able to click on a selected row', async () => { + renderSelectionVariant({ rowSelection: true }); + + await userEvent.click(screen.getByText('Row 1')); + }); }); describe('StructuredListBody', () => { diff --git a/packages/react/src/components/StructuredList/__tabs__/StructuredList.Skeleton-test.js b/packages/react/src/components/StructuredList/__tabs__/StructuredList.Skeleton-test.js new file mode 100644 index 000000000000..19a1792c7edb --- /dev/null +++ b/packages/react/src/components/StructuredList/__tabs__/StructuredList.Skeleton-test.js @@ -0,0 +1,22 @@ +/** + * Copyright IBM Corp. 2016, 2023 + * + * This source code is licensed under the Apache-2.0 license found in the + * LICENSE file in the root directory of this source tree. + */ + +import React from 'react'; +import StructuredListSkeleton from '../StructuredList.Skeleton'; +import { render } from '@testing-library/react'; + +describe('StructuredListSkeleton', () => { + it('should support a custom `className` prop on the outermost element', () => { + const { container } = render(); + expect(container.firstChild).toHaveClass('test'); + }); + + it('should spread additional props on the outermost element', () => { + const { container } = render(); + expect(container.firstChild).toHaveAttribute('data-testid', 'test'); + }); +});