diff --git a/packages/ra-ui-materialui/src/input/AutocompleteInput.spec.tsx b/packages/ra-ui-materialui/src/input/AutocompleteInput.spec.tsx index b722ec57158..8dd85dfa8c6 100644 --- a/packages/ra-ui-materialui/src/input/AutocompleteInput.spec.tsx +++ b/packages/ra-ui-materialui/src/input/AutocompleteInput.spec.tsx @@ -12,6 +12,17 @@ import { Form } from 'react-final-form'; import { TestTranslationProvider } from 'ra-core'; describe('', () => { + //Fix document.createRange is not a function error on fireEvent usage (Fixed in jsdom v16.0.0) + //reported by https://github.com/mui-org/material-ui/issues/15726#issuecomment-493124813 + global.document.createRange = () => ({ + setStart: () => {}, + setEnd: () => {}, + commonAncestorContainer: { + nodeName: 'BODY', + ownerDocument: document, + }, + }); + const defaultProps = { source: 'role', resource: 'users', @@ -34,6 +45,21 @@ describe('', () => { expect(getByRole('combobox')).not.toBeNull(); }); + it('should set AutocompleteInput value to an empty string when the selected item is null', () => { + const { queryByDisplayValue } = render( +
( + + )} + /> + ); + expect(queryByDisplayValue('')).not.toBeNull(); + }); + it('should use the input parameter value as the initial state and input searchText', () => { const { queryByDisplayValue } = render(