Skip to content

Commit

Permalink
add test for #711 (#715)
Browse files Browse the repository at this point in the history
* add test for #711

passing test for #711 (originally from my issue #657)

* Make suggested revisions to test
  • Loading branch information
SkyCaptainess committed Aug 9, 2019
1 parent fb08a3e commit e73103f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/MUIDataTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { spy } from 'sinon';
import { mount, shallow } from 'enzyme';
import { assert, expect } from 'chai';
import cloneDeep from 'lodash.clonedeep';
import MUIDataTable from '../src/MUIDataTable';
import TableFilterList from '../src/components/TableFilterList';
import TablePagination from '../src/components/TablePagination';
Expand Down Expand Up @@ -429,6 +430,21 @@ describe('<MUIDataTable />', function() {
assert.deepEqual(state.filterList, [['Joe James'], [], [], [], []]);
});

it('should apply columns prop change for filterList', () => {
const mountShallowWrapper = mount(shallow(<MUIDataTable columns={columns} data={data} />).get(0));
const instance = mountShallowWrapper.instance();
instance.initializeTable(mountShallowWrapper.props());
// now use updated columns props
const newColumns = cloneDeep(columns);
newColumns[0].options.filterList = ['Joe James'];
mountShallowWrapper.setProps({ columns: newColumns });
mountShallowWrapper.update();
instance.setTableData(mountShallowWrapper.props(), 1 /* instance.TABLE_LOAD.INITIAL */);

const updatedState = mountShallowWrapper.state();
assert.deepEqual(updatedState.filterList, [['Joe James'], [], [], [], []]);
});

it('should create Chip when filterList is populated', () => {
const filterList = [['Joe James'], [], [], [], []];
const filterListRenderers = [
Expand Down

0 comments on commit e73103f

Please sign in to comment.