diff --git a/cspell.json b/cspell.json index c83dd81..0426ec8 100644 --- a/cspell.json +++ b/cspell.json @@ -18,6 +18,7 @@ "Autodocs", "autodocs", "Embla", - "svgs" + "svgs", + "toggleable" ] } diff --git a/spec/components/FilterOption/FilterOption.test.tsx b/spec/components/FilterOption/FilterOption.test.tsx index eed8a41..da07dbc 100644 --- a/spec/components/FilterOption/FilterOption.test.tsx +++ b/spec/components/FilterOption/FilterOption.test.tsx @@ -207,6 +207,26 @@ describe('FilterOption component', () => { ); expect(screen.queryByText('Red')).not.toBeInTheDocument(); }); + + test('render-prop reactNode receives children so nested content can be re-emitted', () => { + render( +
  • {props.children}
  • , + }} + onChange={() => {}}> + Nested +
    , + ); + const override = screen.getByTestId('custom-override'); + expect(override).toBeInTheDocument(); + expect(screen.getByTestId('nested-child')).toBeInTheDocument(); + // The nested child is inside the overridden node, not lost. + expect(override).toContainElement(screen.getByTestId('nested-child')); + }); }); describe('CSS classes', () => { @@ -241,6 +261,20 @@ describe('FilterOption component', () => { const listItem = screen.getByRole('listitem'); expect(listItem.classList.contains('cio:text-base')).toBeTruthy(); }); + + test('label takes the leftover space rather than sizing to its text', () => { + const { container } = render( + {}}> + + , + ); + // `grow basis-0 min-w-0`: a long display value wraps inside the label instead of claiming + // the whole flex line and pushing a sibling (e.g. a hierarchy toggle) onto its own line. + const label = container.querySelector('.cio-filter-option-label'); + expect(label?.classList.contains('cio:grow')).toBeTruthy(); + expect(label?.classList.contains('cio:basis-0')).toBeTruthy(); + expect(label?.classList.contains('cio:min-w-0')).toBeTruthy(); + }); }); describe('data attributes', () => { diff --git a/spec/components/FilterOptionVisual/FilterOptionVisual.test.tsx b/spec/components/FilterOptionVisual/FilterOptionVisual.test.tsx index 86f8a85..518f215 100644 --- a/spec/components/FilterOptionVisual/FilterOptionVisual.test.tsx +++ b/spec/components/FilterOptionVisual/FilterOptionVisual.test.tsx @@ -183,6 +183,61 @@ describe('FilterOptionVisual component', () => { }); }); + describe('children', () => { + test('renders children inside the row', () => { + render( + {}}> + Nested + , + ); + const listItem = screen.getByRole('listitem'); + expect(listItem).toContainElement(screen.getByTestId('nested')); + }); + + test('renders children outside the label, after it', () => { + render( + {}}> + + , + ); + const child = screen.getByTestId('nested-control'); + // Interactive children must stay out of the