Make all fields optional on entities (#121)
* Make all fields optional on entities * Rewrite tests * Add test on TableHeader Cancel button
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
import * as React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import { Opportunity } from '../../interfaces/company.interface';
|
||||
import { Pipe } from '../../interfaces/pipe.interface';
|
||||
|
||||
type OwnProps = {
|
||||
opportunity: Opportunity;
|
||||
opportunity: Pipe;
|
||||
};
|
||||
|
||||
const StyledContainer = styled.span`
|
||||
|
||||
@ -3,7 +3,10 @@ import { ThemeProvider } from '@emotion/react';
|
||||
import { lightTheme } from '../../../../layout/styles/themes';
|
||||
import { StoryFn } from '@storybook/react';
|
||||
import CompanyChip, { CompanyChipPropsType } from '../../../chips/CompanyChip';
|
||||
import { Company, mapCompany } from '../../../../interfaces/company.interface';
|
||||
import {
|
||||
Company,
|
||||
mapToCompany,
|
||||
} from '../../../../interfaces/company.interface';
|
||||
import { MockedProvider } from '@apollo/client/testing';
|
||||
import { SEARCH_COMPANY_QUERY } from '../../../../services/search/search';
|
||||
import styled from '@emotion/styled';
|
||||
@ -76,8 +79,10 @@ EditableRelationStory.args = {
|
||||
ChipComponent: CompanyChip,
|
||||
chipComponentPropsMapper: (company: Company): CompanyChipPropsType => {
|
||||
return {
|
||||
name: company.name,
|
||||
picture: `https://www.google.com/s2/favicons?domain=${company.domain_name}&sz=256`,
|
||||
name: company.name || '',
|
||||
picture: company.domainName
|
||||
? `https://www.google.com/s2/favicons?domain=${company.domainName}&sz=256`
|
||||
: undefined,
|
||||
};
|
||||
},
|
||||
changeHandler: (relation: Company) => {
|
||||
@ -90,7 +95,7 @@ EditableRelationStory.args = {
|
||||
}),
|
||||
resultMapper: (company) => ({
|
||||
render: (company) => company.name,
|
||||
value: mapCompany(company),
|
||||
value: mapToCompany(company),
|
||||
}),
|
||||
} satisfies SearchConfigType<Company>,
|
||||
};
|
||||
|
||||
@ -49,16 +49,15 @@ it('Checks the EditableRelation editing event bubbles up', async () => {
|
||||
});
|
||||
|
||||
await waitFor(() => {
|
||||
expect(func).toBeCalledWith(
|
||||
expect.objectContaining({
|
||||
accountOwner: null,
|
||||
address: undefined,
|
||||
domain_name: 'abnb.com',
|
||||
employees: undefined,
|
||||
id: 'abnb',
|
||||
name: 'Airbnb',
|
||||
opportunities: [],
|
||||
}),
|
||||
);
|
||||
expect(func).toBeCalledWith({
|
||||
accountOwner: undefined,
|
||||
address: undefined,
|
||||
domainName: 'abnb.com',
|
||||
employees: undefined,
|
||||
creationDate: undefined,
|
||||
id: 'abnb',
|
||||
name: 'Airbnb',
|
||||
pipes: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -3,7 +3,7 @@ import { fireEvent, render } from '@testing-library/react';
|
||||
import { RegularTableHeader } from '../__stories__/TableHeader.stories';
|
||||
|
||||
it('Checks the TableHeader renders', async () => {
|
||||
const { getByText } = render(<RegularTableHeader />);
|
||||
const { getByText, queryByText } = render(<RegularTableHeader />);
|
||||
|
||||
const sortDropdownButton = getByText('Sort');
|
||||
fireEvent.click(sortDropdownButton);
|
||||
@ -12,4 +12,9 @@ it('Checks the TableHeader renders', async () => {
|
||||
fireEvent.click(sortByCreatedAt);
|
||||
|
||||
expect(getByText('Created at')).toBeDefined();
|
||||
|
||||
const cancelButton = getByText('Cancel');
|
||||
fireEvent.click(cancelButton);
|
||||
|
||||
expect(queryByText('Created at')).toBeNull();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user