mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-24 22:46:40 +00:00
Fix unit tests
This commit is contained in:
parent
f65e7ab1d6
commit
582d581edf
@ -13,13 +13,14 @@ import {
|
|||||||
SAVE_BUTTON_ID,
|
SAVE_BUTTON_ID,
|
||||||
UPDATE_BUTTON_ID,
|
UPDATE_BUTTON_ID,
|
||||||
UPLOAD_BUTTON_ID,
|
UPLOAD_BUTTON_ID,
|
||||||
|
addStringsNoDuplicate,
|
||||||
buildQuery,
|
buildQuery,
|
||||||
getDiscardExistingDocumentChangesButtonState,
|
getDiscardExistingDocumentChangesButtonState,
|
||||||
getDiscardNewDocumentChangesButtonState,
|
getDiscardNewDocumentChangesButtonState,
|
||||||
getSaveExistingDocumentButtonState,
|
getSaveExistingDocumentButtonState,
|
||||||
getSaveNewDocumentButtonState,
|
getSaveNewDocumentButtonState,
|
||||||
getTabsButtons,
|
getTabsButtons,
|
||||||
showPartitionKey
|
showPartitionKey,
|
||||||
} from "Explorer/Tabs/DocumentsTabV2/DocumentsTabV2";
|
} from "Explorer/Tabs/DocumentsTabV2/DocumentsTabV2";
|
||||||
import { ReactWrapper, ShallowWrapper, mount, shallow } from "enzyme";
|
import { ReactWrapper, ShallowWrapper, mount, shallow } from "enzyme";
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
@ -68,7 +69,7 @@ jest.mock("Explorer/Controls/Dialog", () => ({
|
|||||||
useDialog: {
|
useDialog: {
|
||||||
getState: jest.fn(() => ({
|
getState: jest.fn(() => ({
|
||||||
showOkCancelModalDialog: (title: string, subText: string, okLabel: string, onOk: () => void) => onOk(),
|
showOkCancelModalDialog: (title: string, subText: string, okLabel: string, onOk: () => void) => onOk(),
|
||||||
showOkModalDialog: () => { },
|
showOkModalDialog: () => {},
|
||||||
})),
|
})),
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
@ -339,7 +340,10 @@ describe("Documents tab (noSql API)", () => {
|
|||||||
const createMockProps = (): IDocumentsTabComponentProps => ({
|
const createMockProps = (): IDocumentsTabComponentProps => ({
|
||||||
isPreferredApiMongoDB: false,
|
isPreferredApiMongoDB: false,
|
||||||
documentIds: [],
|
documentIds: [],
|
||||||
collection: undefined,
|
collection: {
|
||||||
|
id: ko.observable<string>("collectionId"),
|
||||||
|
databaseId: "databaseId",
|
||||||
|
} as ViewModels.CollectionBase,
|
||||||
partitionKey: { kind: "Hash", paths: ["/foo"], version: 2 },
|
partitionKey: { kind: "Hash", paths: ["/foo"], version: 2 },
|
||||||
onLoadStartKey: 0,
|
onLoadStartKey: 0,
|
||||||
tabTitle: "",
|
tabTitle: "",
|
||||||
@ -477,6 +481,10 @@ describe("Documents tab (noSql API)", () => {
|
|||||||
|
|
||||||
describe("Documents tab", () => {
|
describe("Documents tab", () => {
|
||||||
it("should add strings to array without duplicate", () => {
|
it("should add strings to array without duplicate", () => {
|
||||||
addStringsNoDuplicates(test this);
|
const array1 = ["a", "b", "c"];
|
||||||
|
const array2 = ["b", "c", "d"];
|
||||||
|
|
||||||
|
const array3 = addStringsNoDuplicate(array1, array2);
|
||||||
|
expect(array3).toEqual(["a", "b", "c", "d"]);
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -1,6 +1,7 @@
|
|||||||
import { TableRowId } from "@fluentui/react-components";
|
import { TableRowId } from "@fluentui/react-components";
|
||||||
import { mount } from "enzyme";
|
import { mount } from "enzyme";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import * as ViewModels from "../../../Contracts/ViewModels";
|
||||||
import { DocumentsTableComponent, IDocumentsTableComponentProps } from "./DocumentsTableComponent";
|
import { DocumentsTableComponent, IDocumentsTableComponentProps } from "./DocumentsTableComponent";
|
||||||
|
|
||||||
const PARTITION_KEY_HEADER = "partitionKey";
|
const PARTITION_KEY_HEADER = "partitionKey";
|
||||||
@ -25,6 +26,10 @@ describe("DocumentsTableComponent", () => {
|
|||||||
partitionKeyHeaders: [PARTITION_KEY_HEADER],
|
partitionKeyHeaders: [PARTITION_KEY_HEADER],
|
||||||
},
|
},
|
||||||
isSelectionDisabled: false,
|
isSelectionDisabled: false,
|
||||||
|
collection: {
|
||||||
|
databaseId: "db",
|
||||||
|
id: ((): string => "coll") as ko.Observable<string>,
|
||||||
|
} as ViewModels.CollectionBase,
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should render documents and partition keys in header", () => {
|
it("should render documents and partition keys in header", () => {
|
||||||
|
@ -527,6 +527,12 @@ exports[`Documents tab (noSql API) when rendered should render the page 1`] = `
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<DocumentsTableComponent
|
<DocumentsTableComponent
|
||||||
|
collection={
|
||||||
|
Object {
|
||||||
|
"databaseId": "databaseId",
|
||||||
|
"id": [Function],
|
||||||
|
}
|
||||||
|
}
|
||||||
columnHeaders={
|
columnHeaders={
|
||||||
Object {
|
Object {
|
||||||
"idHeader": "id",
|
"idHeader": "id",
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
exports[`DocumentsTableComponent should not render selection column when isSelectionDisabled is true 1`] = `
|
exports[`DocumentsTableComponent should not render selection column when isSelectionDisabled is true 1`] = `
|
||||||
<DocumentsTableComponent
|
<DocumentsTableComponent
|
||||||
|
collection={
|
||||||
|
Object {
|
||||||
|
"databaseId": "db",
|
||||||
|
"id": [Function],
|
||||||
|
}
|
||||||
|
}
|
||||||
columnHeaders={
|
columnHeaders={
|
||||||
Object {
|
Object {
|
||||||
"idHeader": "id",
|
"idHeader": "id",
|
||||||
@ -994,6 +1000,12 @@ exports[`DocumentsTableComponent should not render selection column when isSelec
|
|||||||
|
|
||||||
exports[`DocumentsTableComponent should render documents and partition keys in header 1`] = `
|
exports[`DocumentsTableComponent should render documents and partition keys in header 1`] = `
|
||||||
<DocumentsTableComponent
|
<DocumentsTableComponent
|
||||||
|
collection={
|
||||||
|
Object {
|
||||||
|
"databaseId": "db",
|
||||||
|
"id": [Function],
|
||||||
|
}
|
||||||
|
}
|
||||||
columnHeaders={
|
columnHeaders={
|
||||||
Object {
|
Object {
|
||||||
"idHeader": "id",
|
"idHeader": "id",
|
||||||
|
Loading…
Reference in New Issue
Block a user