Create Editable chip to edit cells containing chips (#102)
* Create Editable chip to edit cells containing chips * Fix icons vertical alignment * Fix linter * Fix coverage
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import { fireEvent, render } from '@testing-library/react';
|
||||
|
||||
import { EditableChipStory } from '../__stories__/EditableChip.stories';
|
||||
import CompanyChip from '../../../chips/CompanyChip';
|
||||
|
||||
it('Checks the EditableChip editing event bubbles up', async () => {
|
||||
const func = jest.fn(() => null);
|
||||
const { getByTestId } = render(
|
||||
<EditableChipStory
|
||||
value="test"
|
||||
picture="http://"
|
||||
changeHandler={func}
|
||||
ChipComponent={CompanyChip}
|
||||
/>,
|
||||
);
|
||||
|
||||
const parent = getByTestId('content-editable-parent');
|
||||
|
||||
const wrapper = parent.querySelector('div');
|
||||
|
||||
if (!wrapper) {
|
||||
throw new Error('Editable input not found');
|
||||
}
|
||||
fireEvent.click(wrapper);
|
||||
|
||||
const editableInput = parent.querySelector('input');
|
||||
|
||||
if (!editableInput) {
|
||||
throw new Error('Editable input not found');
|
||||
}
|
||||
|
||||
fireEvent.change(editableInput, { target: { value: 'Test' } });
|
||||
expect(func).toBeCalledWith('Test');
|
||||
});
|
||||
Reference in New Issue
Block a user