mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-28 21:20:04 +00:00
add resolved props factory to generator mock props for body and header
This commit is contained in:
@@ -6,7 +6,9 @@ import Body from 'src/body';
|
||||
import Row from 'src/row';
|
||||
import Const from 'src/const';
|
||||
import RowSection from 'src/row-section';
|
||||
import mockBodyResolvedProps from 'test/mock-data/body-resolved-props';
|
||||
import { bodyResolvedProps } from 'test/factory';
|
||||
|
||||
const mockBodyResolvedProps = bodyResolvedProps();
|
||||
|
||||
describe('Body', () => {
|
||||
let wrapper;
|
||||
|
||||
6
packages/react-bootstrap-table2/test/factory/index.js
vendored
Normal file
6
packages/react-bootstrap-table2/test/factory/index.js
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { bodyResolvedProps, headerResolvedProps } from './resolved-props';
|
||||
|
||||
export {
|
||||
bodyResolvedProps,
|
||||
headerResolvedProps
|
||||
};
|
||||
36
packages/react-bootstrap-table2/test/factory/resolved-props.js
vendored
Normal file
36
packages/react-bootstrap-table2/test/factory/resolved-props.js
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import BootstrapTable from 'src/bootstrap-table';
|
||||
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Name'
|
||||
}];
|
||||
|
||||
const data = [{
|
||||
id: 1,
|
||||
name: 'A'
|
||||
}, {
|
||||
id: 2,
|
||||
name: 'B'
|
||||
}];
|
||||
|
||||
const keyField = 'id';
|
||||
|
||||
const props = {
|
||||
columns,
|
||||
data,
|
||||
keyField
|
||||
};
|
||||
|
||||
const bootstrapTable = new BootstrapTable(props);
|
||||
|
||||
export const bodyResolvedProps = () => ({
|
||||
cellEdit: bootstrapTable.resolveCellEditProps(),
|
||||
selectRow: bootstrapTable.resolveCellSelectionProps()
|
||||
});
|
||||
|
||||
export const headerResolvedProps = () => ({
|
||||
selectRow: bootstrapTable.resolveHeaderCellSelectionProps()
|
||||
});
|
||||
@@ -5,8 +5,9 @@ import HeaderCell from 'src/header-cell';
|
||||
import SelectionHeaderCell from 'src/row-selection/selection-header-cell';
|
||||
import Header from 'src/header';
|
||||
import Const from 'src/const';
|
||||
import { headerResolvedProps } from 'test/factory';
|
||||
|
||||
import mockHeaderResolvedProps from 'test/mock-data/header-resolved-props';
|
||||
const mockHeaderResolvedProps = headerResolvedProps();
|
||||
|
||||
describe('Header', () => {
|
||||
let wrapper;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
import Const from 'src/const';
|
||||
|
||||
const { ROW_SELECT_DISABLED, UNABLE_TO_CELL_EDIT } = Const;
|
||||
|
||||
export const cellSelectionResolvedProps = {
|
||||
mode: ROW_SELECT_DISABLED
|
||||
};
|
||||
|
||||
export const cellEditResolvedProps = {
|
||||
mode: UNABLE_TO_CELL_EDIT
|
||||
};
|
||||
|
||||
export default {
|
||||
cellEdit: cellEditResolvedProps,
|
||||
selectRow: cellSelectionResolvedProps
|
||||
};
|
||||
@@ -1,11 +0,0 @@
|
||||
import Const from 'src/const';
|
||||
|
||||
const { ROW_SELECT_DISABLED } = Const;
|
||||
|
||||
export const headerCellSelectionResolvedProps = {
|
||||
mode: ROW_SELECT_DISABLED
|
||||
};
|
||||
|
||||
export default {
|
||||
selectRow: headerCellSelectionResolvedProps
|
||||
};
|
||||
@@ -7,8 +7,9 @@ import Row from 'src/row';
|
||||
import Const from 'src/const';
|
||||
import EditingCell from 'src/editing-cell';
|
||||
import SelectionCell from 'src/row-selection/selection-cell';
|
||||
import { bodyResolvedProps } from 'test/factory';
|
||||
|
||||
import mockBodyResolvedProps from 'test/mock-data/body-resolved-props';
|
||||
const mockBodyResolvedProps = bodyResolvedProps();
|
||||
|
||||
const defaultColumns = [{
|
||||
dataField: 'id',
|
||||
|
||||
Reference in New Issue
Block a user