mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-06-05 15:12:04 +01: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";
|
const ID_HEADER = "id";
|
||||||
|
|
||||||
describe("DocumentsTableComponent", () => {
|
describe("DocumentsTableComponent", () => {
|
||||||
|
|
||||||
const createMockProps = (): IDocumentsTableComponentProps => ({
|
const createMockProps = (): IDocumentsTableComponentProps => ({
|
||||||
items: [
|
items: [
|
||||||
{ [ID_HEADER]: "1", [PARTITION_KEY_HEADER]: "pk1" },
|
{ [ID_HEADER]: "1", [PARTITION_KEY_HEADER]: "pk1" },
|
||||||
{ [ID_HEADER]: "2", [PARTITION_KEY_HEADER]: "pk2" },
|
{ [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 => {
|
onItemClicked: (index: number): void => {
|
||||||
index;
|
index;
|
||||||
@ -23,12 +22,12 @@ describe("DocumentsTableComponent", () => {
|
|||||||
selectedRows: new Set<TableRowId>(),
|
selectedRows: new Set<TableRowId>(),
|
||||||
size: {
|
size: {
|
||||||
height: 0,
|
height: 0,
|
||||||
width: 0
|
width: 0,
|
||||||
},
|
},
|
||||||
columnHeaders: {
|
columnHeaders: {
|
||||||
idHeader: ID_HEADER,
|
idHeader: ID_HEADER,
|
||||||
partitionKeyHeaders: [PARTITION_KEY_HEADER]
|
partitionKeyHeaders: [PARTITION_KEY_HEADER],
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
let wrapper: ReactWrapper;
|
let wrapper: ReactWrapper;
|
||||||
@ -43,15 +42,35 @@ describe("DocumentsTableComponent", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should show id and partition key(s) in header", () => {
|
it("should show id and partition key(s) in header", () => {
|
||||||
expect(wrapper.find(".fui-TableHeader").findWhere(node => node.text() === ID_HEADER).exists()).toBeTruthy();
|
expect(
|
||||||
expect(wrapper.find(".fui-TableHeader").findWhere(node => node.text() === PARTITION_KEY_HEADER).exists()).toBeTruthy();
|
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", () => {
|
it("should show documents", () => {
|
||||||
const rows = wrapper.find(".fui-TableBody .fui-TableRow");
|
const rows = wrapper.find(".fui-TableBody .fui-TableRow");
|
||||||
expect(rows.length).toBe(3);
|
expect(rows.length).toBe(3);
|
||||||
expect(rows.at(1).findWhere(node => node.text() === "2").exists()).toBeTruthy();
|
expect(
|
||||||
expect(rows.at(1).findWhere(node => node.text() === "pk2").exists()).toBeTruthy();
|
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", () => {
|
it("should clear selection when clicking on row", () => {
|
||||||
const onSelectedRowsChange = jest.fn().mockName('onSelectedRowsChange');
|
const onSelectedRowsChange = jest.fn().mockName("onSelectedRowsChange");
|
||||||
const onItemClicked = jest.fn().mockName('onItemClicked');
|
const onItemClicked = jest.fn().mockName("onItemClicked");
|
||||||
|
|
||||||
const props: IDocumentsTableComponentProps = {
|
const props: IDocumentsTableComponentProps = {
|
||||||
...createMockProps(),
|
...createMockProps(),
|
||||||
@ -71,7 +90,7 @@ describe("DocumentsTableComponent", () => {
|
|||||||
onItemClicked,
|
onItemClicked,
|
||||||
};
|
};
|
||||||
wrapper = mount(<DocumentsTableComponent {...props} />);
|
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(".fui-TableBody .fui-TableCell").findWhere(node => node.text() === "2" && node.type() === "function");
|
||||||
// const cell = wrapper.find("[title~=\"2\"]");
|
// const cell = wrapper.find("[title~=\"2\"]");
|
||||||
cell.at(4).simulate("click");
|
cell.at(4).simulate("click");
|
||||||
@ -81,4 +100,3 @@ describe("DocumentsTableComponent", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user