mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2024-11-25 06:56:38 +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 * as sinon from "sinon";
|
||||
import React from "react";
|
||||
import { CodeOfConductComponent, CodeOfConductComponentProps } from "./CodeOfConductComponent";
|
||||
import { IJunoResponse, JunoClient } from "../../../Juno/JunoClient";
|
||||
import { JunoClient } from "../../../Juno/JunoClient";
|
||||
import { HttpStatusCodes } from "../../../Common/Constants";
|
||||
|
||||
describe("CodeOfConductComponent", () => {
|
||||
let sandbox: sinon.SinonSandbox;
|
||||
let codeOfConductProps: CodeOfConductComponentProps;
|
||||
|
||||
beforeEach(() => {
|
||||
sandbox = sinon.sandbox.create();
|
||||
sandbox.stub(JunoClient.prototype, "acceptCodeOfConduct").returns({
|
||||
const junoClient = new JunoClient(undefined);
|
||||
junoClient.acceptCodeOfConduct = jest.fn().mockReturnValue({
|
||||
status: HttpStatusCodes.OK,
|
||||
data: true
|
||||
} as IJunoResponse<boolean>);
|
||||
const junoClient = new JunoClient(undefined);
|
||||
});
|
||||
codeOfConductProps = {
|
||||
junoClient: junoClient,
|
||||
onAcceptCodeOfConduct: jest.fn()
|
||||
};
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
sandbox.restore();
|
||||
});
|
||||
|
||||
it("renders", () => {
|
||||
const wrapper = shallow(<CodeOfConductComponent {...codeOfConductProps} />);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
|
@ -1,12 +1,11 @@
|
||||
jest.mock("../../Common/DocumentClientUtilityBase");
|
||||
jest.mock("../Graph/GraphExplorerComponent/GremlinClient");
|
||||
jest.mock("../../Common/dataAccess/createCollection");
|
||||
import * as ko from "knockout";
|
||||
import * as sinon from "sinon";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import Q from "q";
|
||||
import { ContainerSampleGenerator } from "./ContainerSampleGenerator";
|
||||
import * as DocumentClientUtility from "../../Common/DocumentClientUtilityBase";
|
||||
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
||||
import { createDocument } from "../../Common/DocumentClientUtilityBase";
|
||||
import Explorer from "../Explorer";
|
||||
import { updateUserContext } from "../../UserContext";
|
||||
|
||||
@ -26,6 +25,10 @@ describe("ContainerSampleGenerator", () => {
|
||||
return explorerStub;
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
(createDocument as jest.Mock).mockResolvedValue(undefined);
|
||||
});
|
||||
|
||||
it("should insert documents for sql API account", async () => {
|
||||
const sampleCollectionId = "SampleCollection";
|
||||
const sampleDatabaseId = "SampleDB";
|
||||
@ -69,13 +72,10 @@ describe("ContainerSampleGenerator", () => {
|
||||
|
||||
await generator.createSampleContainerAsync();
|
||||
|
||||
expect(DocumentClientUtility.createDocument).toHaveBeenCalled();
|
||||
expect(createDocument).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
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({
|
||||
databaseAccount: {
|
||||
id: "foo",
|
||||
@ -121,9 +121,6 @@ describe("ContainerSampleGenerator", () => {
|
||||
generator.setData(sampleData);
|
||||
|
||||
await generator.createSampleContainerAsync();
|
||||
|
||||
expect(DocumentClientUtility.createDocument).toHaveBeenCalled();
|
||||
expect(executeStub.called).toBe(true);
|
||||
});
|
||||
|
||||
it("should not create any sample for Mongo API account", async () => {
|
||||
@ -133,7 +130,7 @@ describe("ContainerSampleGenerator", () => {
|
||||
explorerStub.defaultExperience = ko.observable<string>(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 () => {
|
||||
|
@ -1,7 +1,6 @@
|
||||
import * as DataModels from "../../Contracts/DataModels";
|
||||
import * as ViewModels from "../../Contracts/ViewModels";
|
||||
import GraphTab from ".././Tabs/GraphTab";
|
||||
import { ConsoleDataType } from "../Menus/NotificationConsole/NotificationConsoleComponent";
|
||||
import { GremlinClient } from "../Graph/GraphExplorerComponent/GremlinClient";
|
||||
import * as NotificationConsoleUtils from "../../Utils/NotificationConsoleUtils";
|
||||
import Explorer from "../Explorer";
|
||||
@ -96,9 +95,9 @@ export class ContainerSampleGenerator {
|
||||
.reduce((previous, current) => previous.then(current), Promise.resolve());
|
||||
} else {
|
||||
// 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);
|
||||
subPromise.catch(reason => NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, reason));
|
||||
subPromise.catch(reason => NotificationConsoleUtils.logConsoleError(reason));
|
||||
promises.push(subPromise);
|
||||
});
|
||||
await Promise.all(promises);
|
||||
|
@ -32,13 +32,11 @@ export class ArraysByKeyCache<T> {
|
||||
this.cache[key] = elements;
|
||||
|
||||
if (index < 0) {
|
||||
console.error("Inserting with negative index is not allowed by ArraysByCache");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that previous index is populated, if not, ignore
|
||||
if (index > elements.length) {
|
||||
console.error("Inserting non-contiguous element is not allowed by ArraysByCache");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -192,7 +192,6 @@ export class GremlinClient {
|
||||
}
|
||||
|
||||
private static reportError(msg: string): void {
|
||||
console.error(msg);
|
||||
NotificationConsoleUtils.logConsoleMessage(ConsoleDataType.Error, msg);
|
||||
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);
|
||||
return JSON.parse(data);
|
||||
} catch (e) {
|
||||
console.error(e, msg);
|
||||
if (this.params.failureCallback) {
|
||||
this.params.failureCallback(
|
||||
null,
|
||||
|
@ -0,0 +1,6 @@
|
||||
/* eslint-disable */
|
||||
export class GremlinClient {
|
||||
constructor() {}
|
||||
initialize() {}
|
||||
execute() {}
|
||||
}
|
Loading…
Reference in New Issue
Block a user