diff --git a/docs/examples/filterSort.tsx b/docs/examples/filterSort.tsx index 8124a2b7..f2845557 100644 --- a/docs/examples/filterSort.tsx +++ b/docs/examples/filterSort.tsx @@ -22,7 +22,7 @@ const Test = () => ( filterSort={sorterByLabel} optionFilterProp="label" options={incidencesStateResource} - > + />

without filter sort

@@ -90,5 +90,37 @@ export default function maxTagTextLengthTest(mode: any) { expect(container.firstChild).toMatchSnapshot(); }); + + it('tagRender should work on maxTagPlaceholder', () => { + const tagRender = jest.fn(); + const maxTagPlaceholder = (omittedValues) => ( + `${omittedValues.length} values omitted` + ); + render( + , + ); + expect(tagRender).toHaveBeenCalledWith(expect.objectContaining({ + isMaxTag: false, + label: 'One', + })); + expect(tagRender).toHaveBeenCalledWith(expect.objectContaining({ + isMaxTag: false, + label: 'Two', + })); + expect(tagRender).toHaveBeenCalledWith(expect.objectContaining({ + isMaxTag: true, + label: '1 values omitted', + })); + }); }); } diff --git a/tests/utils/common.ts b/tests/utils/common.ts index de6bed79..ed0d5aaa 100644 --- a/tests/utils/common.ts +++ b/tests/utils/common.ts @@ -1,5 +1,5 @@ +import { act } from 'react'; import { createEvent, fireEvent } from '@testing-library/react'; -import { act } from 'react-dom/test-utils'; export function expectOpen(wrapper: any, open: boolean = true) { if (wrapper instanceof HTMLElement) { @@ -86,7 +86,7 @@ export function injectRunAllTimers(jest: Jest) { originRunAllTimers = jest.runAllTimers; jest.runAllTimers = () => { - let result: typeof jest; + let result; act(() => { result = originRunAllTimers(); });