mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
Test Output Cleanup
This commit is contained in:
parent
b83f59ac31
commit
f5bbd52311
@ -1,31 +1,25 @@
|
|||||||
|
jest.mock("../../../Juno/JunoClient");
|
||||||
import { shallow } from "enzyme";
|
import { shallow } from "enzyme";
|
||||||
import * as sinon from "sinon";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { CodeOfConductComponent, CodeOfConductComponentProps } from "./CodeOfConductComponent";
|
import { CodeOfConductComponent, CodeOfConductComponentProps } from "./CodeOfConductComponent";
|
||||||
import { IJunoResponse, JunoClient } from "../../../Juno/JunoClient";
|
import { JunoClient } from "../../../Juno/JunoClient";
|
||||||
import { HttpStatusCodes } from "../../../Common/Constants";
|
import { HttpStatusCodes } from "../../../Common/Constants";
|
||||||
|
|
||||||
describe("CodeOfConductComponent", () => {
|
describe("CodeOfConductComponent", () => {
|
||||||
let sandbox: sinon.SinonSandbox;
|
|
||||||
let codeOfConductProps: CodeOfConductComponentProps;
|
let codeOfConductProps: CodeOfConductComponentProps;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
sandbox = sinon.sandbox.create();
|
const junoClient = new JunoClient(undefined);
|
||||||
sandbox.stub(JunoClient.prototype, "acceptCodeOfConduct").returns({
|
junoClient.acceptCodeOfConduct = jest.fn().mockReturnValue({
|
||||||
status: HttpStatusCodes.OK,
|
status: HttpStatusCodes.OK,
|
||||||
data: true
|
data: true
|
||||||
} as IJunoResponse<boolean>);
|
});
|
||||||
const junoClient = new JunoClient(undefined);
|
|
||||||
codeOfConductProps = {
|
codeOfConductProps = {
|
||||||
junoClient: junoClient,
|
junoClient: junoClient,
|
||||||
onAcceptCodeOfConduct: jest.fn()
|
onAcceptCodeOfConduct: jest.fn()
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
sandbox.restore();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("renders", () => {
|
it("renders", () => {
|
||||||
const wrapper = shallow(<CodeOfConductComponent {...codeOfConductProps} />);
|
const wrapper = shallow(<CodeOfConductComponent {...codeOfConductProps} />);
|
||||||
expect(wrapper).toMatchSnapshot();
|
expect(wrapper).toMatchSnapshot();
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
jest.mock("../../Common/DocumentClientUtilityBase");
|
jest.mock("../../Common/DocumentClientUtilityBase");
|
||||||
|
jest.mock("../Graph/GraphExplorerComponent/GremlinClient");
|
||||||
jest.mock("../../Common/dataAccess/createCollection");
|
jest.mock("../../Common/dataAccess/createCollection");
|
||||||
import * as ko from "knockout";
|
import * as ko from "knockout";
|
||||||
import * as sinon from "sinon";
|
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import Q from "q";
|
import Q from "q";
|
||||||
import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
|
import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
|
||||||
import * as DocumentClientUtility from "../../Common/DocumentClientUtilityBase";
|
import { createDocument } from "../../Common/DocumentClientUtilityBase";
|
||||||
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
import { updateUserContext } from "../../UserContext";
|
import { updateUserContext } from "../../UserContext";
|
||||||
|
|
||||||
@ -26,6 +25,10 @@ describe("ContainerSampleGenerator", () => {
|
|||||||
return explorerStub;
|
return explorerStub;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
(createDocument as jest.Mock).mockResolvedValue(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
it("should insert documents for sql API account", async () => {
|
it("should insert documents for sql API account", async () => {
|
||||||
const sampleCollectionId = "SampleCollection";
|
const sampleCollectionId = "SampleCollection";
|
||||||
const sampleDatabaseId = "SampleDB";
|
const sampleDatabaseId = "SampleDB";
|
||||||
@ -69,13 +72,10 @@ describe("ContainerSampleGenerator", () => {
|
|||||||
|
|
||||||
await generator.createSampleContainerAsync();
|
await generator.createSampleContainerAsync();
|
||||||
|
|
||||||
expect(DocumentClientUtility.createDocument).toHaveBeenCalled();
|
expect(createDocument).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should send gremlin queries for Graph API account", async () => {
|
it("should send gremlin queries for Graph API account", async () => {
|
||||||
sinon.stub(GremlinClient.prototype, "initialize").callsFake(() => {});
|
|
||||||
const executeStub = sinon.stub(GremlinClient.prototype, "execute").returns(Q.resolve());
|
|
||||||
|
|
||||||
updateUserContext({
|
updateUserContext({
|
||||||
databaseAccount: {
|
databaseAccount: {
|
||||||
id: "foo",
|
id: "foo",
|
||||||
@ -121,9 +121,6 @@ describe("ContainerSampleGenerator", () => {
|
|||||||
generator.setData(sampleData);
|
generator.setData(sampleData);
|
||||||
|
|
||||||
await generator.createSampleContainerAsync();
|
await generator.createSampleContainerAsync();
|
||||||
|
|
||||||
expect(DocumentClientUtility.createDocument).toHaveBeenCalled();
|
|
||||||
expect(executeStub.called).toBe(true);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not create any sample for Mongo API account", async () => {
|
it("should not create any sample for Mongo API account", async () => {
|
||||||
@ -133,7 +130,7 @@ describe("ContainerSampleGenerator", () => {
|
|||||||
explorerStub.defaultExperience = ko.observable<string>(experience);
|
explorerStub.defaultExperience = ko.observable<string>(experience);
|
||||||
|
|
||||||
// Rejects with error that contains experience
|
// Rejects with error that contains experience
|
||||||
await expect(ContainerSampleGenerator.createSampleGeneratorAsync(explorerStub)).rejects.toMatch(experience);
|
expect(ContainerSampleGenerator.createSampleGeneratorAsync(explorerStub)).rejects.toMatch(experience);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should not create any sample for Table API account", async () => {
|
it("should not create any sample for Table API account", async () => {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import * as DataModels from "../../Contracts/DataModels";
|
import * as DataModels from "../../Contracts/DataModels";
|
||||||
import * as ViewModels from "../../Contracts/ViewModels";
|
import * as ViewModels from "../../Contracts/ViewModels";
|
||||||
import GraphTab from ".././Tabs/GraphTab";
|
import GraphTab from ".././Tabs/GraphTab";
|
||||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
|
||||||
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
||||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||||
import Explorer from "../Explorer";
|
import Explorer from "../Explorer";
|
||||||
@ -96,9 +95,9 @@ export class ContainerSampleGenerator {
|
|||||||
.reduce((previous, current) => previous.then(current), Promise.resolve());
|
.reduce((previous, current) => previous.then(current), Promise.resolve());
|
||||||
} else {
|
} else {
|
||||||
// For SQL all queries are executed at the same time
|
// For SQL all queries are executed at the same time
|
||||||
this.sampleDataFile.data.forEach(doc => {
|
this.sampleDataFile.data.map(doc => {
|
||||||
const subPromise = createDocument(collection, doc);
|
const subPromise = createDocument(collection, doc);
|
||||||
subPromise.catch(reason => NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, reason));
|
subPromise.catch(reason => NotificationConsoleUtils.logConsoleError(reason));
|
||||||
promises.push(subPromise);
|
promises.push(subPromise);
|
||||||
});
|
});
|
||||||
await Promise.all(promises);
|
await Promise.all(promises);
|
||||||
|
@ -32,13 +32,11 @@ export class ArraysByKeyCache<T> {
|
|||||||
this.cache[key] = elements;
|
this.cache[key] = elements;
|
||||||
|
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
console.error("Inserting with negative index is not allowed by ArraysByCache");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that previous index is populated, if not, ignore
|
// Check that previous index is populated, if not, ignore
|
||||||
if (index > elements.length) {
|
if (index > elements.length) {
|
||||||
console.error("Inserting non-contiguous element is not allowed by ArraysByCache");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,7 +192,6 @@ export class GremlinClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static reportError(msg: string): void {
|
private static reportError(msg: string): void {
|
||||||
console.error(msg);
|
|
||||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, msg);
|
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, msg);
|
||||||
Logger.logError(msg, GremlinClient.LOG_AREA);
|
Logger.logError(msg, GremlinClient.LOG_AREA);
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,6 @@ export class GremlinSimpleClient {
|
|||||||
const data = typeof msg.data === "string" ? msg.data : new TextDecoder("utf-8").decode(msg.data);
|
const data = typeof msg.data === "string" ? msg.data : new TextDecoder("utf-8").decode(msg.data);
|
||||||
return JSON.parse(data);
|
return JSON.parse(data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e, msg);
|
|
||||||
if (this.params.failureCallback) {
|
if (this.params.failureCallback) {
|
||||||
this.params.failureCallback(
|
this.params.failureCallback(
|
||||||
null,
|
null,
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
/* eslint-disable */
|
||||||
|
export class GremlinClient {
|
||||||
|
constructor() {}
|
||||||
|
initialize() {}
|
||||||
|
execute() {}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user