-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata-table.spec.js
46 lines (43 loc) · 1.37 KB
/
data-table.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import React from "react";
import { shallow } from "enzyme";
import { expect } from "chai";
import { PureDataTable } from "./index";
describe("<DataTable />", () => {
const props = {
rows: {
test: [
{ species: "Bird People", name: "Bridperson", origin: "Bird World" },
{ species: "Plutonian", name: "Snowville", origin: "Pluto" },
{ species: "Zigerion", name: "Prince Nebulon", origin: "Spaceship" }
]
},
columns: {
test: [
{ label: "Species", key: "species", visible: true },
{ label: "Name", key: "name", visible: false },
{ label: "Origin", key: "origin", visible: true }
]
},
dataType: "test",
fetchDatatableData: () => {},
fetchDatatableColumns: () => {}
};
it("should have correct labels on columns", () => {
const wrapper = shallow(<PureDataTable {...props} />);
const expected = "Origin";
const actual = wrapper.find("TableHeaderColumn").at(1).props().children;
expect(actual).equals(expected);
});
it("should have correct row order and display correct data", () => {
const wrapper = shallow(<PureDataTable {...props} />);
const expected = "Spaceship";
const actual = wrapper
.find("TableBody")
.find("TableRow")
.at(2)
.find("TableRowColumn")
.at(1)
.props().children;
expect(actual).equals(expected);
});
});