add resolved props factory to generator mock props for body and header

This commit is contained in:
Chun-MingChen
2017-10-07 23:35:27 +08:00
parent 4e6b341828
commit b6698a5307
7 changed files with 49 additions and 30 deletions

View File

@@ -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;

View File

@@ -0,0 +1,6 @@
import { bodyResolvedProps, headerResolvedProps } from './resolved-props';
export {
bodyResolvedProps,
headerResolvedProps
};

View 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()
});

View File

@@ -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;

View File

@@ -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
};

View File

@@ -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
};

View File

@@ -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',