Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Testing toggle list
  • Loading branch information
eitens-mak committed Jun 19, 2020
commit f1b44e807bf708b7c94a4fbabdbba4a165df483e
61 changes: 61 additions & 0 deletions packages/react-bootstrap-table2-toolkit/test/toggle-list.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import React from 'react';
import { shallow } from 'enzyme';

import ToggleList from '../src/column-toggle/toggle-list';

describe('ToggleList', () => {
const columns = [{
dataField: 'id',
text: 'ID'
}, {
dataField: 'name',
text: 'Name'
}];
const pivotColumns = [{
dataField: 'id',
text: 'ID'
}, {
dataField: 'name',
text: 'Name',
reduce: (T, t) => T + t
}];

let wrapper;
describe('simple toggle list', () => {
beforeEach(() => {
wrapper = shallow(
<ToggleList
columns={ columns }
onColumnToggle={ () => {} }
toggles={ { id: true, name: true } }
contextual={ 'btn-warning' }
className={ 'test' }
btnClassName={ 'test' }
/>
);
});

it('should render successfully', () => {
expect(wrapper.children().length).toBe(2);
});
});

describe('pivot toggle list', () => {
beforeEach(() => {
wrapper = shallow(
<ToggleList
columns={ pivotColumns }
onColumnToggle={ () => {} }
toggles={ { id: true, name: true } }
contextual={ 'btn-warning' }
className={ 'test' }
btnClassName={ 'test' }
/>
);
});

it('should render successfully', () => {
expect(wrapper.children().length).toBe(1);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe('TableResolver', () => {
expect(pivotColumns.some(
column => Object.prototype.hasOwnProperty.call(column, 'reduce')
)).toBeTruthy();
expect(wrapper.instance().visibleRows()).toEqual([{id: 1, name: 'AB'}]);
expect(wrapper.instance().visibleRows()).toEqual([{ id: 1, name: 'AB' }]);
});
});

Expand Down