mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
patch test for #598
This commit is contained in:
parent
828844a1e9
commit
d0fb46e39f
@ -198,6 +198,26 @@ describe('Cell', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when props.tabIndex is change', () => {
|
||||
const column = { dataField: 'name', text: 'Product Name' };
|
||||
beforeEach(() => {
|
||||
props = {
|
||||
row,
|
||||
columnIndex: 1,
|
||||
rowIndex: 1,
|
||||
tabIndex: 5,
|
||||
column
|
||||
};
|
||||
wrapper = shallow(
|
||||
<Cell { ...props } />);
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
nextProps = { ...props, tabIndex: 2 };
|
||||
expect(wrapper.instance().shouldComponentUpdate(nextProps)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('if column.isDummyField is true', () => {
|
||||
describe('when content is change', () => {
|
||||
const column = { dataField: '', text: 'Product Name', isDummyField: true };
|
||||
|
||||
@ -57,6 +57,27 @@ describe('<SelectionCell />', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when tabIndex prop has been changed', () => {
|
||||
beforeEach(() => {
|
||||
props = {
|
||||
selected: false,
|
||||
mode,
|
||||
rowIndex,
|
||||
disabled: false,
|
||||
tabIndex: 0,
|
||||
rowKey: 1
|
||||
};
|
||||
wrapper = shallow(
|
||||
<SelectionCell { ...props } />
|
||||
);
|
||||
});
|
||||
|
||||
it('should return true', () => {
|
||||
nextProps = { ...props, tabIndex: 2 };
|
||||
expect(wrapper.instance().shouldComponentUpdate(nextProps)).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when disabled prop has been changed', () => {
|
||||
beforeEach(() => {
|
||||
props = {
|
||||
|
||||
@ -104,6 +104,47 @@ describe('RowPureContent', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('when tabIndexStart prop is -1', () => {
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<RowPureContent
|
||||
tabIndexStart={ -1 }
|
||||
keyField={ keyField }
|
||||
rowIndex={ rowIndex }
|
||||
columns={ defaultColumns }
|
||||
row={ row }
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
it('should not render tabIndex prop on Cell', () => {
|
||||
wrapper.find(Cell).forEach((cell) => {
|
||||
expect(cell.prop('tabIndex')).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when tabIndexStart prop is not -1', () => {
|
||||
const tabIndexStart = 4;
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<RowPureContent
|
||||
tabIndexStart={ tabIndexStart }
|
||||
keyField={ keyField }
|
||||
rowIndex={ rowIndex }
|
||||
columns={ defaultColumns }
|
||||
row={ row }
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
it('should render correct tabIndex prop on Cell', () => {
|
||||
wrapper.find(Cell).forEach((cell, i) => {
|
||||
expect(cell.prop('tabIndex')).toEqual(tabIndexStart + i);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('when editingRowIdx and editingColIdx prop is defined', () => {
|
||||
const editingRowIdx = rowIndex;
|
||||
const editingColIdx = 1;
|
||||
|
||||
@ -57,6 +57,49 @@ describe('SimpleRow', () => {
|
||||
expect(wrapper.length).toBe(1);
|
||||
expect(wrapper.find(RowPureContent)).toHaveLength(1);
|
||||
});
|
||||
|
||||
describe('when tabIndexCell prop is enable', () => {
|
||||
const visibleColumnSize = 3;
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<SimpleRow
|
||||
keyField={ keyField }
|
||||
rowIndex={ rowIndex }
|
||||
columns={ defaultColumns }
|
||||
row={ row }
|
||||
tabIndexCell
|
||||
visibleColumnSize={ visibleColumnSize }
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
it('should render correct tabIndexStart', () => {
|
||||
expect(wrapper.length).toBe(1);
|
||||
expect(wrapper.find(RowPureContent)).toHaveLength(1);
|
||||
expect(wrapper.find(RowPureContent).prop('tabIndexStart')).toBe((rowIndex * visibleColumnSize) + 1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when tabIndexCell prop is disable', () => {
|
||||
const visibleColumnSize = 3;
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(
|
||||
<SimpleRow
|
||||
keyField={ keyField }
|
||||
rowIndex={ rowIndex }
|
||||
columns={ defaultColumns }
|
||||
row={ row }
|
||||
visibleColumnSize={ visibleColumnSize }
|
||||
/>
|
||||
);
|
||||
});
|
||||
|
||||
it('should always render tabIndexStart as -1', () => {
|
||||
expect(wrapper.length).toBe(1);
|
||||
expect(wrapper.find(RowPureContent)).toHaveLength(1);
|
||||
expect(wrapper.find(RowPureContent).prop('tabIndexStart')).toBe(-1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('shouldComponentUpdate', () => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user