Create and EditableRelation component and make it generic (#107)

* Create and EditableRelation component and make it generic

* Refactor EditableCell component to be more flexible

* Complete Company picker on people page

* Fix lint
This commit is contained in:
Charles Bochet
2023-05-06 16:08:45 +02:00
committed by GitHub
parent 7ac2f8e1a6
commit 41c46c36ed
21 changed files with 637 additions and 198 deletions

View File

@ -1,6 +1,6 @@
import { fireEvent, render } from '@testing-library/react';
import { RegularSortDropdownButton } from '../__stories__/SortDropdownButton.stories';
import { FaEnvelope } from 'react-icons/fa';
import { FaEnvelope, FaRegBuilding } from 'react-icons/fa';
it('Checks the default top option is Ascending', async () => {
const setSorts = jest.fn();
@ -49,3 +49,26 @@ it('Checks the selection of Descending', async () => {
_type: 'default_sort',
});
});
it('Checks custom_sort is working', async () => {
const setSorts = jest.fn();
const { getByText } = render(
<RegularSortDropdownButton setSorts={setSorts} />,
);
const sortDropdownButton = getByText('Sort');
fireEvent.click(sortDropdownButton);
const sortByCompany = getByText('Company');
fireEvent.click(sortByCompany);
expect(setSorts).toHaveBeenCalledWith(
expect.objectContaining({
key: 'company_name',
label: 'Company',
icon: <FaRegBuilding />,
_type: 'custom_sort',
order: 'asc',
}),
);
});