diff --git a/packages/sn-client-core/test/repository.test.ts b/packages/sn-client-core/test/repository.test.ts index 624b3caec..4cae1c969 100644 --- a/packages/sn-client-core/test/repository.test.ts +++ b/packages/sn-client-core/test/repository.test.ts @@ -98,13 +98,12 @@ describe('Repository', () => { describe('count', () => { it('should construct the url to contain /$count', async () => { - let url: string const countRepository = new Repository(undefined, input => { - url = input.toString() + const url = input.toString() + expect(url).toMatch(/http:\/\/localhost\/odata.svc\/Root\/Content\/\$count/g) return Promise.resolve({ ok: true, json: () => 42 }) as any }) await countRepository.count({ path: '/Root/Content' }) - expect(url).toMatch(/http:\/\/localhost\/odata.svc\/Root\/Content\/\$count/g) }) it('should throw on unsuccessfull request', async () => { diff --git a/packages/sn-controls-react/src/fieldcontrols/TagsInput.tsx b/packages/sn-controls-react/src/fieldcontrols/TagsInput.tsx index 9c19f694e..32987e31c 100644 --- a/packages/sn-controls-react/src/fieldcontrols/TagsInput.tsx +++ b/packages/sn-controls-react/src/fieldcontrols/TagsInput.tsx @@ -177,7 +177,7 @@ export class TagsInput extends Component c.Id) : [] } - return this.state.fieldValue.length ? [this.state.fieldValue[0].Id] : [] + return this.state.fieldValue.length ? [this.state.fieldValue[0].Id] : '' } public render() { @@ -204,7 +204,7 @@ export class TagsInput extends Component { describe('in browse view', () => { it('should show the value of the field when content is passed', async () => { - const consoleSpy = jest.spyOn(console, 'error') const wrapper = mount( { repository={repository} />, ) - expect(consoleSpy).not.toBeCalled() await sleepAsync(0) const updatedWrapper = wrapper.update() expect(updatedWrapper.find(FormControlLabel).children()).toHaveLength(1) }) it('should not show anything when field value is not provided', () => { - const wrapper = shallow() + const wrapper = shallow() expect(wrapper.get(0)).toBeFalsy() }) }) diff --git a/packages/sn-controls-react/test/__mocks__/schema.ts b/packages/sn-controls-react/test/__mocks__/schema.ts index c4d32974c..bad5d9b07 100644 --- a/packages/sn-controls-react/test/__mocks__/schema.ts +++ b/packages/sn-controls-react/test/__mocks__/schema.ts @@ -9,6 +9,7 @@ export const schema = [ AllowIndexing: true, AllowIncrementalNaming: false, AllowedChildTypes: [], + HandlerName: 'a', FieldSettings: [ { Name: 'DisplayName', diff --git a/packages/sn-list-controls-react/src/ContentList/CellTemplates/ActionsCell.tsx b/packages/sn-list-controls-react/src/ContentList/CellTemplates/ActionsCell.tsx index dbb331dd5..26b63bbc7 100644 --- a/packages/sn-list-controls-react/src/ContentList/CellTemplates/ActionsCell.tsx +++ b/packages/sn-list-controls-react/src/ContentList/CellTemplates/ActionsCell.tsx @@ -57,7 +57,7 @@ export class ActionsCell extends React.Component = props => { } : {} } - component="div"> + component={props.virtual ? 'div' : 'td'}> {props.date} ) diff --git a/packages/sn-list-controls-react/src/ContentList/CellTemplates/ReferenceCell.tsx b/packages/sn-list-controls-react/src/ContentList/CellTemplates/ReferenceCell.tsx index 0923d14ba..e276dc158 100644 --- a/packages/sn-list-controls-react/src/ContentList/CellTemplates/ReferenceCell.tsx +++ b/packages/sn-list-controls-react/src/ContentList/CellTemplates/ReferenceCell.tsx @@ -25,7 +25,7 @@ export class ReferenceCell extends React.Component + component={virtual ? 'div' : 'td'}> {content[fieldName]} ) diff --git a/packages/sn-list-controls-react/src/ContentList/ContentList.tsx b/packages/sn-list-controls-react/src/ContentList/ContentList.tsx index 018ef7f69..4b0446e99 100644 --- a/packages/sn-list-controls-react/src/ContentList/ContentList.tsx +++ b/packages/sn-list-controls-react/src/ContentList/ContentList.tsx @@ -138,34 +138,29 @@ export const ContentList: React.FC> = props => /> ) : null} - {props.fieldsToDisplay - ? props.fieldsToDisplay.map(field => { - const fieldSetting = getSchemaForField(field) - const isNumeric = - fieldSetting && - (fieldSetting.Type === 'IntegerFieldSetting' || fieldSetting.Type === 'NumberFieldSetting') - const description = (fieldSetting && fieldSetting.Description) || field - const displayName = (fieldSetting && fieldSetting.DisplayName) || field - return ( - - - - props.onRequestOrderChange && - props.onRequestOrderChange(field, props.orderDirection === 'asc' ? 'desc' : 'asc') - }> - {displayName} - - - - ) - }) - : null} + {props.fieldsToDisplay.map(field => { + const fieldSetting = getSchemaForField(field) + const isNumeric = + fieldSetting && + (fieldSetting.Type === 'IntegerFieldSetting' || fieldSetting.Type === 'NumberFieldSetting') + const description = (fieldSetting && fieldSetting.Description) || field + const displayName = (fieldSetting && fieldSetting.DisplayName) || field + return ( + + + + props.onRequestOrderChange && + props.onRequestOrderChange(field, props.orderDirection === 'asc' ? 'desc' : 'asc') + }> + {displayName} + + + + ) + })} )} @@ -202,21 +197,19 @@ export const ContentList: React.FC> = props => )} ) : null} - {props.fieldsToDisplay - ? props.fieldsToDisplay.map(field => { - const fieldSetting = getSchemaForField(field) - const cellProps: CellProps = { - ...(props as ContentListProps), - field, - content: item, - fieldSetting, - isSelected, - } + {props.fieldsToDisplay.map(field => { + const fieldSetting = getSchemaForField(field) + const cellProps: CellProps = { + ...(props as ContentListProps), + field, + content: item, + fieldSetting, + isSelected, + } - const FieldComponent = props.fieldComponent || defaultFieldComponents - return - }) - : null} + const FieldComponent = props.fieldComponent || defaultFieldComponents + return + })} ) })} diff --git a/packages/sn-list-controls-react/test/__snapshots__/content-list.test.tsx.snap b/packages/sn-list-controls-react/test/__snapshots__/content-list.test.tsx.snap index a152e0be5..ca8d8fb04 100644 --- a/packages/sn-list-controls-react/test/__snapshots__/content-list.test.tsx.snap +++ b/packages/sn-list-controls-react/test/__snapshots__/content-list.test.tsx.snap @@ -3177,54 +3177,6 @@ exports[`ContentList component Selection and active item changes Event bindings `; -exports[`ContentList component Selection and active item changes Event bindings should render without crashing without fieldsToDisplay 1`] = ` - - - - - - - - - - - - - - - - -`; - exports[`ContentList component Selection and active item changes Event bindings should render without crashing without icons 1`] = ` diff --git a/packages/sn-list-controls-react/test/content-list.test.tsx b/packages/sn-list-controls-react/test/content-list.test.tsx index ad7142292..456e7b3c1 100644 --- a/packages/sn-list-controls-react/test/content-list.test.tsx +++ b/packages/sn-list-controls-react/test/content-list.test.tsx @@ -682,21 +682,6 @@ describe('ContentList component', () => { expect(component).toMatchSnapshot() component.unmount() }) - it('should render without crashing without fieldsToDisplay', () => { - const component = shallow( - , - ) - expect(component).toMatchSnapshot() - component.unmount() - }) }) }) }) diff --git a/packages/sn-list-controls-react/test/virtualized-table.test.tsx b/packages/sn-list-controls-react/test/virtualized-table.test.tsx index 38bad8b50..3f2aa9577 100644 --- a/packages/sn-list-controls-react/test/virtualized-table.test.tsx +++ b/packages/sn-list-controls-react/test/virtualized-table.test.tsx @@ -119,7 +119,7 @@ describe('Virtualized Table component', () => { height: 400, width: 800, headerHeight: 42, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -165,7 +165,7 @@ describe('Virtualized Table component', () => { height: 400, width: 800, headerHeight: 42, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -208,7 +208,7 @@ describe('Virtualized Table component', () => { height: 400, width: 800, headerHeight: 42, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -250,7 +250,7 @@ describe('Virtualized Table component', () => { height: 400, width: 800, headerHeight: 42, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -292,7 +292,7 @@ describe('Virtualized Table component', () => { height: 400, width: 800, headerHeight: 42, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -324,12 +324,12 @@ describe('Virtualized Table component', () => { headerHeight: 42, height: 400, width: 800, - onRowClick: rowMouseEventHandlerParams => { + onRowClick: (rowMouseEventHandlerParams: any) => { expect(rowMouseEventHandlerParams.rowData.Id).toBe(1) component.unmount() done() }, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -390,7 +390,7 @@ describe('Virtualized Table component', () => { height: 400, width: 800, headerHeight: 42, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -426,7 +426,7 @@ describe('Virtualized Table component', () => { width: 800, rowHeight: 57, headerHeight: 42, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -463,7 +463,7 @@ describe('Virtualized Table component', () => { headerHeight: 42, height: 400, width: 800, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -506,7 +506,7 @@ describe('Virtualized Table component', () => { headerHeight: 42, height: 400, width: 800, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -536,9 +536,7 @@ describe('Virtualized Table component', () => { cellRenderer={props => { if (props.tableCellProps.dataKey === 'Name') { return ( - -
{props.tableCellProps.rowData[props.tableCellProps.dataKey]}
- + {props.tableCellProps.rowData[props.tableCellProps.dataKey]} ) } return null @@ -550,7 +548,7 @@ describe('Virtualized Table component', () => { headerHeight: 42, width: 800, height: 400, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -586,12 +584,12 @@ describe('Virtualized Table component', () => { headerHeight: 42, height: 400, width: 800, - onRowClick: rowMouseEventHandlerParams => { + onRowClick: (rowMouseEventHandlerParams: any) => { expect(rowMouseEventHandlerParams.rowData.Id).toBe(1) component.unmount() done() }, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -621,12 +619,12 @@ describe('Virtualized Table component', () => { headerHeight: 42, height: 400, width: 800, - onRowDoubleClick: param => { + onRowDoubleClick: (param: any) => { expect(param.rowData.Id).toBe(1) component.unmount() done() }, - rowGetter: ({ index }) => items[index], + rowGetter: ({ index }: any) => items[index], } as any } /> @@ -708,7 +706,7 @@ describe('Virtualized Table component', () => { { { { { { { { { }) describe('serviceChecks()', () => { describe('Given repository.getSchema() resolves', () => { - let data + let data: any let mockSchemaResponseData: ReturnType beforeEach(async () => { data = await Actions.getSchema().payload(repo) @@ -1018,7 +1018,7 @@ describe('Actions', () => { describe('serviceChecks()', () => { describe('Given repository.removeSharing() resolves', () => { - let data: ODataSharingResponse + let data: any const expectedResult = { Token: 'devdog@sensenet.com', Id: 11 } beforeEach(async () => { data = await Actions.removeSharing({ Id: 42 } as GenericContent, 11).payload(repo)