mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 23:16:56 +00:00
More improvements to table unit tests
This commit is contained in:
parent
a80da7654b
commit
0203bd9674
@ -7,12 +7,11 @@ const PARTITION_KEY_HEADER = "partitionKey";
|
||||
const ID_HEADER = "id";
|
||||
|
||||
describe("DocumentsTableComponent", () => {
|
||||
|
||||
const createMockProps = (): IDocumentsTableComponentProps => ({
|
||||
items: [
|
||||
{ [ID_HEADER]: "1", [PARTITION_KEY_HEADER]: "pk1" },
|
||||
{ [ID_HEADER]: "2", [PARTITION_KEY_HEADER]: "pk2" },
|
||||
{ [ID_HEADER]: "3", [PARTITION_KEY_HEADER]: "pk3" }
|
||||
{ [ID_HEADER]: "3", [PARTITION_KEY_HEADER]: "pk3" },
|
||||
],
|
||||
onItemClicked: (index: number): void => {
|
||||
index;
|
||||
@ -23,12 +22,12 @@ describe("DocumentsTableComponent", () => {
|
||||
selectedRows: new Set<TableRowId>(),
|
||||
size: {
|
||||
height: 0,
|
||||
width: 0
|
||||
width: 0,
|
||||
},
|
||||
columnHeaders: {
|
||||
idHeader: ID_HEADER,
|
||||
partitionKeyHeaders: [PARTITION_KEY_HEADER]
|
||||
}
|
||||
partitionKeyHeaders: [PARTITION_KEY_HEADER],
|
||||
},
|
||||
});
|
||||
|
||||
let wrapper: ReactWrapper;
|
||||
@ -43,15 +42,35 @@ describe("DocumentsTableComponent", () => {
|
||||
});
|
||||
|
||||
it("should show id and partition key(s) in header", () => {
|
||||
expect(wrapper.find(".fui-TableHeader").findWhere(node => node.text() === ID_HEADER).exists()).toBeTruthy();
|
||||
expect(wrapper.find(".fui-TableHeader").findWhere(node => node.text() === PARTITION_KEY_HEADER).exists()).toBeTruthy();
|
||||
expect(
|
||||
wrapper
|
||||
.find(".fui-TableHeader")
|
||||
.findWhere((node) => node.text() === ID_HEADER)
|
||||
.exists(),
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
wrapper
|
||||
.find(".fui-TableHeader")
|
||||
.findWhere((node) => node.text() === PARTITION_KEY_HEADER)
|
||||
.exists(),
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it("should show documents", () => {
|
||||
const rows = wrapper.find(".fui-TableBody .fui-TableRow");
|
||||
expect(rows.length).toBe(3);
|
||||
expect(rows.at(1).findWhere(node => node.text() === "2").exists()).toBeTruthy();
|
||||
expect(rows.at(1).findWhere(node => node.text() === "pk2").exists()).toBeTruthy();
|
||||
expect(
|
||||
rows
|
||||
.at(1)
|
||||
.findWhere((node) => node.text() === "2")
|
||||
.exists(),
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
rows
|
||||
.at(1)
|
||||
.findWhere((node) => node.text() === "pk2")
|
||||
.exists(),
|
||||
).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@ -61,8 +80,8 @@ describe("DocumentsTableComponent", () => {
|
||||
});
|
||||
|
||||
it("should clear selection when clicking on row", () => {
|
||||
const onSelectedRowsChange = jest.fn().mockName('onSelectedRowsChange');
|
||||
const onItemClicked = jest.fn().mockName('onItemClicked');
|
||||
const onSelectedRowsChange = jest.fn().mockName("onSelectedRowsChange");
|
||||
const onItemClicked = jest.fn().mockName("onItemClicked");
|
||||
|
||||
const props: IDocumentsTableComponentProps = {
|
||||
...createMockProps(),
|
||||
@ -71,7 +90,7 @@ describe("DocumentsTableComponent", () => {
|
||||
onItemClicked,
|
||||
};
|
||||
wrapper = mount(<DocumentsTableComponent {...props} />);
|
||||
const cell = wrapper.find(".fui-TableBody .fui-TableCell").findWhere(node => node.text() === "2");
|
||||
const cell = wrapper.find(".fui-TableBody .fui-TableCell").findWhere((node) => node.text() === "2");
|
||||
// const cell = wrapper.find(".fui-TableBody .fui-TableCell").findWhere(node => node.text() === "2" && node.type() === "function");
|
||||
// const cell = wrapper.find("[title~=\"2\"]");
|
||||
cell.at(4).simulate("click");
|
||||
@ -81,4 +100,3 @@ describe("DocumentsTableComponent", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user