Skip to content

Commit

Permalink
update unit tests to reflect changed caused by withDataStyles removal
Browse files Browse the repository at this point in the history
  • Loading branch information
gregnb committed Dec 22, 2017
1 parent b08a20b commit e60a00d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
11 changes: 3 additions & 8 deletions src/MUIDataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import debounce from "lodash.debounce";
import { getStyle, DataStyles } from "./DataStyles";

const defaultTableStyles = {
main: {
}
main: {},
};

class MUIDataTable extends React.Component {
Expand Down Expand Up @@ -338,11 +337,7 @@ class MUIDataTable extends React.Component {
styles={getStyle(this.options, "table.main")}>
{tableStyles => (
<Table ref={el => (this.tableRef = el)} className={tableStyles.main}>
<MUIDataTableHead
columns={columns}
toggleSort={this.toggleSortColumn}
options={this.options}
/>
<MUIDataTableHead columns={columns} toggleSort={this.toggleSortColumn} options={this.options} />
<MUIDataTableBody
data={this.state.displayData}
columns={columns}
Expand All @@ -366,7 +361,7 @@ class MUIDataTable extends React.Component {
)}
</Table>
)}
</DataStyles>
</DataStyles>
</Paper>
);
}
Expand Down
5 changes: 1 addition & 4 deletions src/MUIDataTableSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ class MUIDataTableSearch extends React.Component {
const { classes, onHide, onSearch, options } = this.props;

return (
<DataStyles
defaultStyles={defaultSearchStyles}
name="MUIDataTableSearch"
styles={getStyle(options, "search")}>
<DataStyles defaultStyles={defaultSearchStyles} name="MUIDataTableSearch" styles={getStyle(options, "search")}>
{headStyles => (
<Grow appear in={true} timeout={300}>
<div className={headStyles.main} ref={el => (this.rootRef = el)}>
Expand Down
1 change: 0 additions & 1 deletion src/MUIDataTableToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ const defaultFilterStyles = {
},
};


class MUIDataTableToolbar extends React.Component {
state = {
iconActive: null,
Expand Down
26 changes: 13 additions & 13 deletions test/MUIDataTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ describe("<MUIDataTable />", function() {

it("should render a table", () => {
const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />);
assert.strictEqual(shallowWrapper.dive().name(), "MUIDataTable");
assert.strictEqual(shallowWrapper.dive().name(), "Paper");
});


it("should correctly build internal columns data structure", () => {
const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />);
const actualResult = shallowWrapper.dive().dive().state().columns;
const actualResult = shallowWrapper.state().columns;
const expectedResult = [
{ display: true, name: "First Name", sort: "desc" },
{ display: true, name: "Company", sort: "desc" },
Expand All @@ -37,17 +38,17 @@ describe("<MUIDataTable />", function() {
assert.deepEqual(actualResult, expectedResult);
});


it("should correctly build internal table data and displayData structure", () => {
const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />);
const state = shallowWrapper.dive().dive().state();
const state = shallowWrapper.state();
assert.deepEqual(state.data, data);
assert.deepEqual(state.displayData, data);
});


it("should correctly build internal filterList structure", () => {
const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />);
const state = shallowWrapper.dive().dive().state();
const state = shallowWrapper.state();
const expectedResult = [[],[],[],[]];

assert.deepEqual(state.filterList, expectedResult);
Expand All @@ -56,7 +57,7 @@ describe("<MUIDataTable />", function() {

it("should correctly build internal unique column data for filterData structure", () => {
const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />);
const state = shallowWrapper.dive().dive().state();
const state = shallowWrapper.state();
const expectedResult = [
["Joe James", "John Walsh", "Bob Herm", "James Houston"],
["Test Corp"],
Expand All @@ -75,7 +76,7 @@ describe("<MUIDataTable />", function() {
};

const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} options={options} />);
const state = shallowWrapper.dive().dive().state();
const state = shallowWrapper.state();
assert.strictEqual(state.rowsPerPage, 20);

});
Expand All @@ -88,7 +89,7 @@ describe("<MUIDataTable />", function() {
};

const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} options={options} />);
const state = shallowWrapper.dive().dive().state();
const state = shallowWrapper.state();
assert.deepEqual(state.rowsPerPageOptions, [5, 10, 15]);

});
Expand Down Expand Up @@ -122,7 +123,7 @@ describe("<MUIDataTable />", function() {
it("should properly set internal filterList when calling filterUpdate method", () => {

const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />);
const table = shallowWrapper.dive().dive();
const table = shallowWrapper;
const instance = table.instance();
instance.filterUpdate(0, "Joe James", "checkbox");
table.update();
Expand All @@ -136,7 +137,7 @@ describe("<MUIDataTable />", function() {

// set a filter
const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />);
const table = shallowWrapper.dive().dive();
const table = shallowWrapper;
const instance = table.instance();
instance.filterUpdate(0, "Joe James", "checkbox");
table.update();
Expand All @@ -155,7 +156,7 @@ describe("<MUIDataTable />", function() {
it("should properly set searchText when calling searchTextUpdate method", () => {

const shallowWrapper = shallow(<MUIDataTable columns={columns} data={data} />);
const table = shallowWrapper.dive().dive();
const table = shallowWrapper;
const instance = table.instance();

instance.searchTextUpdate("Joe James");
Expand All @@ -165,6 +166,5 @@ describe("<MUIDataTable />", function() {
assert.deepEqual(state.displayData, [["Joe James", "Test Corp", "Yonkers", "NY"]]);

});



});

0 comments on commit e60a00d

Please sign in to comment.