beforeEach(() => { getRowChange.mockImplementation(() => ({})); tableRowsWithEditing.mockImplementation(() => 'tableRowsWithEditing'); isEditTableCell.mockImplementation(() => false); isAddedTableRow.mockImplementation(() => false); isEditTableRow.mockImplementation(() => false); });
it('should render edit row by using rowComponent', () => { isEditTableRow.mockImplementation(() => true); const tree = mount({ render() { return ( <DxPluginHost> <PluginDepsToComponents deps={defaultDeps} /> <DxTableEditRow {...{ attrs: { ...defaultProps } }} rowHeight={120} /> </DxPluginHost> ); }, }); expect(isEditTableRow) .toBeCalledWith(defaultDeps.template.tableRow.tableRow); expect(tree.find(defaultProps.rowComponent).vm.$attrs) .toMatchObject({ ...defaultDeps.template.tableRow, row: defaultDeps.template.tableRow.tableRow.row, }); });
it('should render cancel command when row is editing', () => { isEditCommandsTableCell.mockImplementation(() => true); isEditTableRow.mockImplementation(() => true); const tree = mount({ render() { return ( <DxPluginHost> <PluginDepsToComponents deps={defaultDeps} /> <DxTableEditColumn {...{ attrs: { ...defaultProps } }} messages={{}} /> </DxPluginHost> ); }, }); const cancelComponent = findCommandWithId(tree, 'cancel').at(0); expect(cancelComponent.vm.$attrs) .toMatchObject({ text: 'cancelCommand' }); cancelComponent.vm.$emit('execute'); expect(defaultDeps.action.stopEditRows.mock.calls[0][0]) .toEqual({ rowIds: [defaultDeps.template.tableCell.tableRow.rowId] }); expect(defaultDeps.action.cancelChangedRows.mock.calls[0][0]) .toEqual({ rowIds: [defaultDeps.template.tableCell.tableRow.rowId] }); });
beforeEach(() => { tableColumnsWithEditing.mockImplementation(() => 'tableColumnsWithEditing'); isHeadingEditCommandsTableCell.mockImplementation(() => false); isDataEditCommandsTableCell.mockImplementation(() => false); isEditCommandsTableCell.mockImplementation(() => false); isAddedTableRow.mockImplementation(() => false); isEditTableRow.mockImplementation(() => false); getMessagesFormatter.mockImplementation(messages => key => (messages[key] || key)); });
it('should not render delete command when row is editing', () => { isEditCommandsTableCell.mockImplementation(() => true); isEditTableRow.mockImplementation(() => true); const tree = mount({ render() { return ( <DxPluginHost> <PluginDepsToComponents deps={defaultDeps} /> <DxTableEditColumn {...{ attrs: { ...defaultProps } }} messages={{}} showDeleteCommand /> </DxPluginHost> ); }, }); expect(findCommandWithId(tree, 'edit').exists()) .toBeFalsy(); });