mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2025-10-16 11:55:39 +00:00
Merge branch 'issue-363' of https://github.com/COzero/react-bootstrap-table2 into COzero-issue-363
This commit is contained in:
commit
2b6081ab31
@ -52,6 +52,7 @@
|
|||||||
"css-loader": "0.28.1",
|
"css-loader": "0.28.1",
|
||||||
"enzyme": "3.3.0",
|
"enzyme": "3.3.0",
|
||||||
"enzyme-adapter-react-16": "1.1.1",
|
"enzyme-adapter-react-16": "1.1.1",
|
||||||
|
"enzyme-to-json": "^3.3.4",
|
||||||
"eslint": "4.5.0",
|
"eslint": "4.5.0",
|
||||||
"eslint-config-airbnb": "15.1.0",
|
"eslint-config-airbnb": "15.1.0",
|
||||||
"eslint-loader": "1.9.0",
|
"eslint-loader": "1.9.0",
|
||||||
|
|||||||
@ -75,6 +75,7 @@ export default class SelectionCell extends Component {
|
|||||||
checked={ selected }
|
checked={ selected }
|
||||||
disabled={ disabled }
|
disabled={ disabled }
|
||||||
className={ bootstrap4 ? 'selection-input-4' : '' }
|
className={ bootstrap4 ? 'selection-input-4' : '' }
|
||||||
|
onChange={ () => {} }
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ export const CheckBox = ({ className, checked, indeterminate }) => (
|
|||||||
ref={ (input) => {
|
ref={ (input) => {
|
||||||
if (input) input.indeterminate = indeterminate; // eslint-disable-line no-param-reassign
|
if (input) input.indeterminate = indeterminate; // eslint-disable-line no-param-reassign
|
||||||
} }
|
} }
|
||||||
|
onChange={ () => {} }
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,14 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`<SelectionCell /> render should render component correctly 1`] = `
|
||||||
|
<td
|
||||||
|
onClick={[Function]}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
checked={true}
|
||||||
|
className=""
|
||||||
|
onChange={[Function]}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
`;
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
|
exports[`<CheckBox /> render should render component correctly 1`] = `
|
||||||
|
<input
|
||||||
|
checked={true}
|
||||||
|
onChange={[Function]}
|
||||||
|
type="checkbox"
|
||||||
|
/>
|
||||||
|
`;
|
||||||
@ -1,6 +1,7 @@
|
|||||||
import 'jsdom-global/register';
|
import 'jsdom-global/register';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
|
import toJson from 'enzyme-to-json';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
|
|
||||||
import { shallowWithContext } from '../test-helpers/new-context';
|
import { shallowWithContext } from '../test-helpers/new-context';
|
||||||
@ -61,7 +62,8 @@ describe('<SelectionCell />', () => {
|
|||||||
mode={ mode }
|
mode={ mode }
|
||||||
rowIndex={ rowIndex }
|
rowIndex={ rowIndex }
|
||||||
onRowSelect={ mockOnRowSelect }
|
onRowSelect={ mockOnRowSelect }
|
||||||
/>, { bootstrap4: false }
|
/>,
|
||||||
|
{ bootstrap4: false }
|
||||||
);
|
);
|
||||||
wrapper.find('td').simulate('click');
|
wrapper.find('td').simulate('click');
|
||||||
});
|
});
|
||||||
@ -72,9 +74,7 @@ describe('<SelectionCell />', () => {
|
|||||||
|
|
||||||
it('should calling onRowSelect callback correctly', () => {
|
it('should calling onRowSelect callback correctly', () => {
|
||||||
expect(mockOnRowSelect.calledOnce).toBe(true);
|
expect(mockOnRowSelect.calledOnce).toBe(true);
|
||||||
expect(
|
expect(mockOnRowSelect.calledWith(rowKey, !selected, rowIndex)).toBe(true);
|
||||||
mockOnRowSelect.calledWith(rowKey, !selected, rowIndex)
|
|
||||||
).toBe(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -88,7 +88,8 @@ describe('<SelectionCell />', () => {
|
|||||||
rowIndex={ rowIndex }
|
rowIndex={ rowIndex }
|
||||||
onRowSelect={ mockOnRowSelect }
|
onRowSelect={ mockOnRowSelect }
|
||||||
disabled
|
disabled
|
||||||
/>, { bootstrap4: false }
|
/>,
|
||||||
|
{ bootstrap4: false }
|
||||||
);
|
);
|
||||||
wrapper.find('td').simulate('click');
|
wrapper.find('td').simulate('click');
|
||||||
});
|
});
|
||||||
@ -111,7 +112,8 @@ describe('<SelectionCell />', () => {
|
|||||||
mode="radio"
|
mode="radio"
|
||||||
rowIndex={ rowIndex }
|
rowIndex={ rowIndex }
|
||||||
onRowSelect={ mockOnRowSelect }
|
onRowSelect={ mockOnRowSelect }
|
||||||
/>, { bootstrap4: false }
|
/>,
|
||||||
|
{ bootstrap4: false }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -132,11 +134,12 @@ describe('<SelectionCell />', () => {
|
|||||||
rowIndex={ rowIndex }
|
rowIndex={ rowIndex }
|
||||||
selected
|
selected
|
||||||
onRowSelect={ mockOnRowSelect }
|
onRowSelect={ mockOnRowSelect }
|
||||||
/>, { bootstrap4: false }
|
/>,
|
||||||
|
{ bootstrap4: false }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be called with correct paramters', () => {
|
it('should be called with correct parameters', () => {
|
||||||
// first click
|
// first click
|
||||||
wrapper.find('td').simulate('click');
|
wrapper.find('td').simulate('click');
|
||||||
expect(mockOnRowSelect.callCount).toBe(1);
|
expect(mockOnRowSelect.callCount).toBe(1);
|
||||||
@ -151,12 +154,8 @@ describe('<SelectionCell />', () => {
|
|||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
wrapper = shallowWithContext(
|
wrapper = shallowWithContext(
|
||||||
<SelectionCell
|
<SelectionCell rowKey={ 1 } mode={ mode } rowIndex={ rowIndex } selected={ selected } />,
|
||||||
rowKey={ 1 }
|
{ bootstrap4: false }
|
||||||
mode={ mode }
|
|
||||||
rowIndex={ rowIndex }
|
|
||||||
selected={ selected }
|
|
||||||
/>, { bootstrap4: false }
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -165,6 +164,7 @@ describe('<SelectionCell />', () => {
|
|||||||
expect(wrapper.find('input')).toHaveLength(1);
|
expect(wrapper.find('input')).toHaveLength(1);
|
||||||
expect(wrapper.find('input').get(0).props.type).toBe(mode);
|
expect(wrapper.find('input').get(0).props.type).toBe(mode);
|
||||||
expect(wrapper.find('input').get(0).props.checked).toBe(selected);
|
expect(wrapper.find('input').get(0).props.checked).toBe(selected);
|
||||||
|
expect(toJson(wrapper)).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('when disabled prop give as true', () => {
|
describe('when disabled prop give as true', () => {
|
||||||
@ -176,7 +176,8 @@ describe('<SelectionCell />', () => {
|
|||||||
rowIndex={ rowIndex }
|
rowIndex={ rowIndex }
|
||||||
selected={ selected }
|
selected={ selected }
|
||||||
disabled
|
disabled
|
||||||
/>, { bootstrap4: false }
|
/>,
|
||||||
|
{ bootstrap4: false }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -198,7 +199,8 @@ describe('<SelectionCell />', () => {
|
|||||||
rowIndex={ rowIndex }
|
rowIndex={ rowIndex }
|
||||||
selected={ selected }
|
selected={ selected }
|
||||||
selectionRenderer={ selectionRenderer }
|
selectionRenderer={ selectionRenderer }
|
||||||
/>, { bootstrap4: false }
|
/>,
|
||||||
|
{ bootstrap4: false }
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -219,12 +221,8 @@ describe('<SelectionCell />', () => {
|
|||||||
describe('when bootstrap4 context is true', () => {
|
describe('when bootstrap4 context is true', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
wrapper = shallowWithContext(
|
wrapper = shallowWithContext(
|
||||||
<SelectionCell
|
<SelectionCell rowKey={ 1 } mode={ mode } rowIndex={ rowIndex } selected={ selected } />,
|
||||||
rowKey={ 1 }
|
{ bootstrap4: true }
|
||||||
mode={ mode }
|
|
||||||
rowIndex={ rowIndex }
|
|
||||||
selected={ selected }
|
|
||||||
/>, { bootstrap4: true }
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { shallow } from 'enzyme';
|
import { shallow } from 'enzyme';
|
||||||
|
import toJson from 'enzyme-to-json';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
|
|
||||||
import { shallowWithContext } from '../test-helpers/new-context';
|
import { shallowWithContext } from '../test-helpers/new-context';
|
||||||
@ -201,6 +202,7 @@ describe('<CheckBox />', () => {
|
|||||||
expect(wrapper.find('input').length).toBe(1);
|
expect(wrapper.find('input').length).toBe(1);
|
||||||
expect(wrapper.find('input').prop('checked')).toBe(checked);
|
expect(wrapper.find('input').prop('checked')).toBe(checked);
|
||||||
expect(wrapper.find('input').prop('type')).toBe('checkbox');
|
expect(wrapper.find('input').prop('type')).toBe('checkbox');
|
||||||
|
expect(toJson(wrapper)).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user