mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-28 21:20:04 +00:00
Compare commits
7 Commits
feature/st
...
mock-props
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
788fcfc93d | ||
|
|
1e816c3f2b | ||
|
|
2a7ec721d7 | ||
|
|
b6698a5307 | ||
|
|
4e6b341828 | ||
|
|
8769f10d17 | ||
|
|
d8a6807f1b |
@@ -11,11 +11,12 @@
|
||||
],
|
||||
"rules": {
|
||||
"comma-dangle": ["error", "never"],
|
||||
"react/jsx-curly-spacing": 0,
|
||||
"react/forbid-prop-types": 0,
|
||||
"react/jsx-curly-spacing": 0,
|
||||
"react/jsx-filename-extension": 0,
|
||||
"react/jsx-space-before-closing": 0,
|
||||
"react/jsx-tag-spacing": ["error", { "beforeSelfClosing": "always" }],
|
||||
"react/require-default-props": 0,
|
||||
"import/extensions": 0, // skip import extensions
|
||||
"import/no-unresolved": [0, { "ignore": ["^react-bootstrap-table"] }], // monorepo setup
|
||||
"import/prefer-default-export": 0,
|
||||
|
||||
@@ -74,6 +74,11 @@
|
||||
"testEnvironment": "node",
|
||||
"testMatch": [
|
||||
"**/test/**/*.test.js"
|
||||
],
|
||||
"moduleFileExtensions": ["js", "jsx"],
|
||||
"moduleDirectories": [
|
||||
"node_modules",
|
||||
"packages/react-bootstrap-table2"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/* eslint no-console: 0 */
|
||||
|
||||
import React from 'react';
|
||||
import ReactDom from 'react-dom';
|
||||
|
||||
|
||||
1
packages/react-bootstrap-table2/src/body.js
vendored
1
packages/react-bootstrap-table2/src/body.js
vendored
@@ -1,5 +1,4 @@
|
||||
/* eslint react/prop-types: 0 */
|
||||
/* eslint react/require-default-props: 0 */
|
||||
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint react/require-default-props: 0 */
|
||||
import React from 'react';
|
||||
import cs from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint react/require-default-props: 0 */
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Const from './const';
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
/* eslint
|
||||
react/require-default-props: 0
|
||||
jsx-a11y/no-noninteractive-element-interactions: 0
|
||||
*/
|
||||
/* eslint jsx-a11y/no-noninteractive-element-interactions: 0 */
|
||||
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Const from '../const';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* eslint react/require-default-props: 0 */
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Constant from '../const';
|
||||
|
||||
@@ -2,33 +2,22 @@ import React from 'react';
|
||||
import sinon from 'sinon';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
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 Body from 'src/body';
|
||||
import Row from 'src/row';
|
||||
import Const from 'src/const';
|
||||
import RowSection from 'src/row-section';
|
||||
import { baseColumns, baseData, baseProps, bodyResolvedProps } from 'test/factory';
|
||||
|
||||
const columns = baseColumns();
|
||||
const data = baseData();
|
||||
const mockBodyResolvedProps = bodyResolvedProps();
|
||||
|
||||
describe('Body', () => {
|
||||
let wrapper;
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Name'
|
||||
}];
|
||||
|
||||
const data = [{
|
||||
id: 1,
|
||||
name: 'A'
|
||||
}, {
|
||||
id: 2,
|
||||
name: 'B'
|
||||
}];
|
||||
|
||||
describe('simplest body', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<Body {...mockBodyResolvedProps} keyField="id" columns={ columns } data={ data } />);
|
||||
wrapper = shallow(<Body {...baseProps} {...mockBodyResolvedProps} />);
|
||||
});
|
||||
|
||||
it('should render successfully', () => {
|
||||
@@ -42,10 +31,8 @@ describe('Body', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<Body
|
||||
{...baseProps}
|
||||
{...mockBodyResolvedProps}
|
||||
keyField="id"
|
||||
columns={ columns }
|
||||
data={ data }
|
||||
visibleColumnSize={ columns.length }
|
||||
isEmpty
|
||||
/>);
|
||||
@@ -67,10 +54,8 @@ describe('Body', () => {
|
||||
emptyIndication = 'Table is empty';
|
||||
wrapper = shallow(
|
||||
<Body
|
||||
{...baseProps}
|
||||
{...mockBodyResolvedProps}
|
||||
keyField="id"
|
||||
columns={ columns }
|
||||
data={ data }
|
||||
visibleColumnSize={ columns.length }
|
||||
noDataIndication={ emptyIndication }
|
||||
isEmpty
|
||||
@@ -93,10 +78,8 @@ describe('Body', () => {
|
||||
emptyIndicationCallBack = sinon.stub().returns(content);
|
||||
wrapper = shallow(
|
||||
<Body
|
||||
{...baseProps}
|
||||
{...mockBodyResolvedProps}
|
||||
keyField="id"
|
||||
columns={ columns }
|
||||
data={ data }
|
||||
visibleColumnSize={ columns.length }
|
||||
noDataIndication={ emptyIndicationCallBack }
|
||||
isEmpty
|
||||
@@ -127,10 +110,8 @@ describe('Body', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<Body
|
||||
{...baseProps}
|
||||
{...mockBodyResolvedProps}
|
||||
data={ data }
|
||||
columns={ columns }
|
||||
keyField={ keyField }
|
||||
cellEdit={ cellEdit }
|
||||
/>
|
||||
);
|
||||
@@ -150,16 +131,13 @@ describe('Body', () => {
|
||||
});
|
||||
|
||||
describe('when selectRow.mode is checkbox or radio (row was selectable)', () => {
|
||||
const keyField = 'id';
|
||||
const selectRow = { mode: 'checkbox' };
|
||||
|
||||
it('props selected should be true if all rows were selected', () => {
|
||||
wrapper = shallow(
|
||||
<Body
|
||||
{...baseProps}
|
||||
{...mockBodyResolvedProps}
|
||||
data={ data }
|
||||
columns={ columns }
|
||||
keyField={ keyField }
|
||||
selectedRowKeys={[1, 2]}
|
||||
selectRow={selectRow}
|
||||
/>
|
||||
@@ -171,10 +149,8 @@ describe('Body', () => {
|
||||
it('props selected should be false if all rows were not selected', () => {
|
||||
wrapper = shallow(
|
||||
<Body
|
||||
{...baseProps}
|
||||
{...mockBodyResolvedProps}
|
||||
data={ data }
|
||||
columns={ columns }
|
||||
keyField={ keyField }
|
||||
selectedRowKeys={[]}
|
||||
selectRow={selectRow}
|
||||
/>
|
||||
@@ -186,13 +162,10 @@ describe('Body', () => {
|
||||
|
||||
describe('when selectRow.mode is ROW_SELECT_DISABLED (row was un-selectable)', () => {
|
||||
beforeEach(() => {
|
||||
const keyField = 'id';
|
||||
wrapper = shallow(
|
||||
<Body
|
||||
{...baseProps}
|
||||
{...mockBodyResolvedProps}
|
||||
data={ data }
|
||||
columns={ columns }
|
||||
keyField={ keyField }
|
||||
selectedRowKeys={[]}
|
||||
/>
|
||||
);
|
||||
|
||||
@@ -2,33 +2,20 @@ import React from 'react';
|
||||
import sinon from 'sinon';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import Caption from '../src/caption';
|
||||
import Header from '../src/header';
|
||||
import Body from '../src/body';
|
||||
import BootstrapTable from '../src/bootstrap-table';
|
||||
import Const from '../src/const';
|
||||
import Caption from 'src/caption';
|
||||
import BootstrapTable from 'src/bootstrap-table';
|
||||
import Header from 'src/header';
|
||||
import Body from 'src/body';
|
||||
import Const from 'src/const';
|
||||
import { baseData, baseProps } from 'test/factory';
|
||||
|
||||
describe('BootstrapTable', () => {
|
||||
let wrapper;
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Name'
|
||||
}];
|
||||
|
||||
const data = [{
|
||||
id: 1,
|
||||
name: 'A'
|
||||
}, {
|
||||
id: 2,
|
||||
name: 'B'
|
||||
}];
|
||||
const data = baseData();
|
||||
|
||||
describe('simplest table', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<BootstrapTable keyField="id" columns={ columns } data={ data } />);
|
||||
wrapper = shallow(<BootstrapTable {...baseProps} />);
|
||||
});
|
||||
|
||||
it('should render successfully', () => {
|
||||
@@ -52,7 +39,7 @@ describe('BootstrapTable', () => {
|
||||
|
||||
describe('when hover props is true', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<BootstrapTable keyField="id" columns={ columns } data={ data } hover />);
|
||||
wrapper = shallow(<BootstrapTable {...baseProps} hover />);
|
||||
});
|
||||
|
||||
it('should have table-hover class on table', () => {
|
||||
@@ -62,7 +49,7 @@ describe('BootstrapTable', () => {
|
||||
|
||||
describe('when striped props is true', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<BootstrapTable keyField="id" columns={ columns } data={ data } striped />);
|
||||
wrapper = shallow(<BootstrapTable {...baseProps} striped />);
|
||||
});
|
||||
|
||||
it('should have table-striped class on table', () => {
|
||||
@@ -72,7 +59,7 @@ describe('BootstrapTable', () => {
|
||||
|
||||
describe('when condensed props is true', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<BootstrapTable keyField="id" columns={ columns } data={ data } condensed />);
|
||||
wrapper = shallow(<BootstrapTable {...baseProps} condensed />);
|
||||
});
|
||||
|
||||
it('should have table-condensed class on table', () => {
|
||||
@@ -82,7 +69,7 @@ describe('BootstrapTable', () => {
|
||||
|
||||
describe('when bordered props is false', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<BootstrapTable keyField="id" columns={ columns } data={ data } bordered={ false } />);
|
||||
wrapper = shallow(<BootstrapTable {...baseProps} bordered={ false } />);
|
||||
});
|
||||
|
||||
it('should not have table-condensed class on table', () => {
|
||||
@@ -94,10 +81,8 @@ describe('BootstrapTable', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<BootstrapTable
|
||||
{...baseProps}
|
||||
caption={ <span className="table-caption">test</span> }
|
||||
keyField="id"
|
||||
columns={ columns }
|
||||
data={ data }
|
||||
bordered={ false }
|
||||
/>
|
||||
);
|
||||
@@ -120,9 +105,7 @@ describe('BootstrapTable', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
columns={ columns }
|
||||
data={ data }
|
||||
{...baseProps}
|
||||
bordered={ false }
|
||||
cellEdit={ cellEdit }
|
||||
/>
|
||||
@@ -148,9 +131,7 @@ describe('BootstrapTable', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
columns={ columns }
|
||||
data={ data }
|
||||
{...baseProps}
|
||||
selectRow={{ mode: 'radio' }}
|
||||
/>
|
||||
);
|
||||
@@ -169,9 +150,7 @@ describe('BootstrapTable', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
columns={ columns }
|
||||
data={ data }
|
||||
{...baseProps}
|
||||
selectRow={{ mode: 'checkbox' }}
|
||||
/>
|
||||
);
|
||||
@@ -197,11 +176,7 @@ describe('BootstrapTable', () => {
|
||||
describe('handleAllRowsSelect', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<BootstrapTable
|
||||
keyField="id"
|
||||
columns={ columns }
|
||||
data={ data }
|
||||
/>
|
||||
<BootstrapTable {...baseProps} />
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -2,21 +2,17 @@ import React from 'react';
|
||||
import sinon from 'sinon';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import Const from '../src/const';
|
||||
import Cell from '../src/cell';
|
||||
import Const from 'src/const';
|
||||
import Cell from 'src/cell';
|
||||
|
||||
import { baseColumn, baseRow } from 'test/factory';
|
||||
|
||||
describe('Cell', () => {
|
||||
let wrapper;
|
||||
const row = {
|
||||
id: 1,
|
||||
name: 'A'
|
||||
};
|
||||
const row = baseRow();
|
||||
|
||||
describe('simplest cell', () => {
|
||||
const column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
const column = baseColumn();
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<Cell row={ row } columnIndex={ 1 } rowIndex={ 1 } column={ column } />);
|
||||
@@ -30,8 +26,7 @@ describe('Cell', () => {
|
||||
|
||||
describe('when column.hidden prop is true', () => {
|
||||
const column = {
|
||||
dataField: 'id',
|
||||
text: 'ID',
|
||||
...baseColumn(),
|
||||
hidden: true
|
||||
};
|
||||
|
||||
@@ -49,8 +44,7 @@ describe('Cell', () => {
|
||||
describe('when column.formatter prop is defined', () => {
|
||||
const rowIndex = 1;
|
||||
const column = {
|
||||
dataField: 'id',
|
||||
text: 'ID',
|
||||
...baseColumn(),
|
||||
formatExtraData: []
|
||||
};
|
||||
const formatterResult = (<h3>{ row[column.dataField] }</h3>);
|
||||
@@ -85,10 +79,7 @@ describe('Cell', () => {
|
||||
const rowIndex = 1;
|
||||
|
||||
beforeEach(() => {
|
||||
column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
column = baseColumn();
|
||||
});
|
||||
|
||||
describe('when style is an object', () => {
|
||||
@@ -139,10 +130,7 @@ describe('Cell', () => {
|
||||
const rowIndex = 1;
|
||||
|
||||
beforeEach(() => {
|
||||
column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
column = baseColumn();
|
||||
});
|
||||
|
||||
describe('when classes is an object', () => {
|
||||
@@ -193,10 +181,7 @@ describe('Cell', () => {
|
||||
const rowIndex = 1;
|
||||
|
||||
beforeEach(() => {
|
||||
column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
column = baseColumn();
|
||||
});
|
||||
|
||||
describe('when title is boolean', () => {
|
||||
@@ -246,8 +231,7 @@ describe('Cell', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
column = {
|
||||
dataField: 'id',
|
||||
text: 'ID',
|
||||
...baseColumn(),
|
||||
events: {
|
||||
onClick: sinon.stub()
|
||||
}
|
||||
@@ -274,10 +258,7 @@ describe('Cell', () => {
|
||||
const rowIndex = 1;
|
||||
|
||||
beforeEach(() => {
|
||||
column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
column = baseColumn();
|
||||
});
|
||||
|
||||
describe('when align is string', () => {
|
||||
@@ -326,10 +307,7 @@ describe('Cell', () => {
|
||||
const rowIndex = 1;
|
||||
|
||||
beforeEach(() => {
|
||||
column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
column = baseColumn();
|
||||
});
|
||||
|
||||
describe('when attrs is an object', () => {
|
||||
@@ -453,10 +431,7 @@ describe('Cell', () => {
|
||||
let onStartCallBack;
|
||||
const rowIndex = 1;
|
||||
const columnIndex = 1;
|
||||
const column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
const column = baseColumn();
|
||||
|
||||
beforeEach(() => {
|
||||
onStartCallBack = sinon.stub().withArgs(rowIndex, columnIndex);
|
||||
|
||||
@@ -3,24 +3,20 @@ import React from 'react';
|
||||
import sinon from 'sinon';
|
||||
import { shallow, mount } from 'enzyme';
|
||||
|
||||
import { TableRowWrapper } from './test-helpers/table-wrapper';
|
||||
import EditingCell from '../src/editing-cell';
|
||||
import TextEditor from '../src/text-editor';
|
||||
import EditorIndicator from '../src/editor-indicator';
|
||||
import EditingCell from 'src/editing-cell';
|
||||
import TextEditor from 'src/text-editor';
|
||||
import EditorIndicator from 'src/editor-indicator';
|
||||
|
||||
import { TableRowWrapper } from 'test/test-helpers/table-wrapper';
|
||||
import { baseColumn, baseRow } from 'test/factory';
|
||||
|
||||
describe('EditingCell', () => {
|
||||
let wrapper;
|
||||
let onEscape;
|
||||
let onComplete;
|
||||
const row = {
|
||||
id: 1,
|
||||
name: 'A'
|
||||
};
|
||||
const row = baseRow();
|
||||
|
||||
let column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
let column = baseColumn();
|
||||
|
||||
beforeEach(() => {
|
||||
onComplete = sinon.stub();
|
||||
|
||||
30
packages/react-bootstrap-table2/test/factory/base-props.js
vendored
Normal file
30
packages/react-bootstrap-table2/test/factory/base-props.js
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
export const baseColumns = () => [{
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Name'
|
||||
}];
|
||||
|
||||
export const baseColumn = () => ({ dataField: 'id', text: 'ID' });
|
||||
|
||||
export const baseData = () => [{
|
||||
id: 1,
|
||||
name: 'A'
|
||||
}, {
|
||||
id: 2,
|
||||
name: 'B'
|
||||
}];
|
||||
|
||||
export const baseRow = () => ({ id: 1, name: 'A' });
|
||||
|
||||
export const baseKeyField = () => 'id';
|
||||
|
||||
/**
|
||||
* baseProps contains those basical props marked as `required` in BootstrapTable
|
||||
*/
|
||||
export const baseProps = {
|
||||
columns: baseColumns(),
|
||||
data: baseData(),
|
||||
keyField: baseKeyField()
|
||||
};
|
||||
19
packages/react-bootstrap-table2/test/factory/index.js
vendored
Normal file
19
packages/react-bootstrap-table2/test/factory/index.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { bodyResolvedProps, headerResolvedProps } from './resolved-props';
|
||||
import {
|
||||
baseColumns, baseColumn, baseData,
|
||||
baseKeyField, baseRow, baseProps
|
||||
} from './base-props';
|
||||
|
||||
/**
|
||||
* Provide the base props in order to test easiler.
|
||||
*/
|
||||
export {
|
||||
bodyResolvedProps,
|
||||
headerResolvedProps,
|
||||
baseColumns,
|
||||
baseColumn,
|
||||
baseData,
|
||||
baseRow,
|
||||
baseKeyField,
|
||||
baseProps
|
||||
};
|
||||
13
packages/react-bootstrap-table2/test/factory/resolved-props.js
vendored
Normal file
13
packages/react-bootstrap-table2/test/factory/resolved-props.js
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
import BootstrapTable from 'src/bootstrap-table';
|
||||
import { baseProps as props } from './base-props';
|
||||
|
||||
const bootstrapTable = new BootstrapTable(props);
|
||||
|
||||
export const bodyResolvedProps = () => ({
|
||||
cellEdit: bootstrapTable.resolveCellEditProps(),
|
||||
selectRow: bootstrapTable.resolveCellSelectionProps()
|
||||
});
|
||||
|
||||
export const headerResolvedProps = () => ({
|
||||
selectRow: bootstrapTable.resolveHeaderCellSelectionProps()
|
||||
});
|
||||
@@ -2,20 +2,19 @@ import React from 'react';
|
||||
import sinon from 'sinon';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import Const from '../src/const';
|
||||
import SortCaret from '../src/sort-caret';
|
||||
import SortSymbol from '../src/sort-symbol';
|
||||
import HeaderCell from '../src/header-cell';
|
||||
import Const from 'src/const';
|
||||
import SortCaret from 'src/sort-caret';
|
||||
import SortSymbol from 'src/sort-symbol';
|
||||
import HeaderCell from 'src/header-cell';
|
||||
|
||||
import { baseColumn } from 'test/factory';
|
||||
|
||||
describe('HeaderCell', () => {
|
||||
let wrapper;
|
||||
const index = 1;
|
||||
|
||||
describe('simplest header cell', () => {
|
||||
const column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
const column = baseColumn();
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<HeaderCell column={ column } index={ index } />);
|
||||
@@ -35,8 +34,7 @@ describe('HeaderCell', () => {
|
||||
|
||||
describe('when column.hidden props is true', () => {
|
||||
const column = {
|
||||
dataField: 'id',
|
||||
text: 'ID',
|
||||
...baseColumn(),
|
||||
hidden: true
|
||||
};
|
||||
|
||||
@@ -142,10 +140,8 @@ describe('HeaderCell', () => {
|
||||
});
|
||||
|
||||
describe('when column.headerFormatter prop is defined', () => {
|
||||
const column = {
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
};
|
||||
const column = baseColumn();
|
||||
|
||||
const formatterResult = (<h3>{ column.text }</h3>);
|
||||
const formatter = sinon.stub()
|
||||
.withArgs(column, index)
|
||||
|
||||
@@ -1,21 +1,17 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
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 mockHeaderResolvedProps from '../test/mock-data/header-resolved-props';
|
||||
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, baseColumns } from 'test/factory';
|
||||
|
||||
const mockHeaderResolvedProps = headerResolvedProps();
|
||||
|
||||
describe('Header', () => {
|
||||
let wrapper;
|
||||
const columns = [{
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Name'
|
||||
}];
|
||||
const columns = baseColumns();
|
||||
|
||||
describe('simplest header', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -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
|
||||
};
|
||||
@@ -2,27 +2,16 @@ import React, { Component } from 'react';
|
||||
import sinon from 'sinon';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import { extendTo } from '../test-helpers/mock-component';
|
||||
import baseResolver from '../../src/props-resolver/index';
|
||||
import Const from '../../src/const';
|
||||
import baseResolver from 'src/props-resolver/index';
|
||||
import Const from 'src/const';
|
||||
import { extendTo } from 'test/test-helpers/mock-component';
|
||||
import { baseColumns, baseData, baseKeyField } from 'test/factory';
|
||||
|
||||
const columns = baseColumns();
|
||||
const data = baseData();
|
||||
const keyField = baseKeyField();
|
||||
|
||||
describe('TableResolver', () => {
|
||||
const keyField = 'id';
|
||||
const columns = [{
|
||||
dataField: keyField,
|
||||
text: 'ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Name'
|
||||
}];
|
||||
const data = [{
|
||||
id: 1,
|
||||
name: 'A'
|
||||
}, {
|
||||
id: 2,
|
||||
name: 'B'
|
||||
}];
|
||||
|
||||
const ExtendBase = baseResolver(Component);
|
||||
const BootstrapTableMock = extendTo(ExtendBase);
|
||||
let wrapper;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import RowSection from '../src/row-section';
|
||||
import RowSection from 'src/row-section';
|
||||
|
||||
describe('Row', () => {
|
||||
const colSpan = 3;
|
||||
|
||||
@@ -2,7 +2,7 @@ import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import SelectionCell from '../../src/row-selection/selection-cell';
|
||||
import SelectionCell from 'src/row-selection/selection-cell';
|
||||
|
||||
describe('<SelectionCell />', () => {
|
||||
const mode = 'checkbox';
|
||||
|
||||
@@ -2,8 +2,8 @@ import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import sinon from 'sinon';
|
||||
|
||||
import Constant from '../../src/const';
|
||||
import SelectionHeaderCell, { CheckBox } from '../../src/row-selection/selection-header-cell';
|
||||
import Constant from 'src/const';
|
||||
import SelectionHeaderCell, { CheckBox } from 'src/row-selection/selection-header-cell';
|
||||
|
||||
let wrapper;
|
||||
|
||||
|
||||
@@ -2,32 +2,21 @@ import React from 'react';
|
||||
import sinon from 'sinon';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import Cell from '../src/cell';
|
||||
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 mockBodyResolvedProps from '../test/mock-data/body-resolved-props';
|
||||
import Cell from 'src/cell';
|
||||
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, baseColumns, baseRow } from 'test/factory';
|
||||
|
||||
const defaultColumns = [{
|
||||
dataField: 'id',
|
||||
text: 'ID'
|
||||
}, {
|
||||
dataField: 'name',
|
||||
text: 'Name'
|
||||
}, {
|
||||
dataField: 'price',
|
||||
text: 'Price'
|
||||
}];
|
||||
const mockBodyResolvedProps = bodyResolvedProps();
|
||||
|
||||
const defaultColumns = baseColumns();
|
||||
|
||||
describe('Row', () => {
|
||||
let wrapper;
|
||||
|
||||
const row = {
|
||||
id: 1,
|
||||
name: 'A',
|
||||
price: 1000
|
||||
};
|
||||
const row = baseRow();
|
||||
|
||||
describe('simplest row', () => {
|
||||
beforeEach(() => {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import Const from '../src/const';
|
||||
import SortCaret from '../src/sort-caret';
|
||||
import Const from 'src/const';
|
||||
import SortCaret from 'src/sort-caret';
|
||||
|
||||
describe('SortCaret', () => {
|
||||
let wrapper;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import SortSymbol from '../src/sort-symbol';
|
||||
import SortSymbol from 'src/sort-symbol';
|
||||
|
||||
describe('SortSymbol', () => {
|
||||
let wrapper;
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import Base from '../../src/store/base';
|
||||
import Const from '../../src/const';
|
||||
import _ from '../../src/utils';
|
||||
import Base from 'src/store/base';
|
||||
import Const from 'src/const';
|
||||
import _ from 'src/utils';
|
||||
import { baseKeyField } from 'test/factory';
|
||||
|
||||
const keyField = baseKeyField();
|
||||
|
||||
describe('Store Base', () => {
|
||||
let store;
|
||||
@@ -13,7 +16,7 @@ describe('Store Base', () => {
|
||||
{ id: 4, name: '123tester' },
|
||||
{ id: 1, name: '!@#' }
|
||||
];
|
||||
store = new Base({ data, keyField: 'id' });
|
||||
store = new Base({ data, keyField });
|
||||
});
|
||||
|
||||
describe('initialize', () => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import sinon from 'sinon';
|
||||
|
||||
import { sort } from '../../src/store/sort';
|
||||
import Const from '../../src/const';
|
||||
import { sort } from 'src/store/sort';
|
||||
import Const from 'src/const';
|
||||
|
||||
describe('Sort Function', () => {
|
||||
const data = [
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
|
||||
import TextEditor from '../src/text-editor';
|
||||
import TextEditor from 'src/text-editor';
|
||||
|
||||
describe('TextEditor', () => {
|
||||
let wrapper;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import _ from '../src/utils';
|
||||
import _ from 'src/utils';
|
||||
|
||||
describe('Utils', () => {
|
||||
describe('get', () => {
|
||||
|
||||
Reference in New Issue
Block a user