mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-06-13 16:07:26 +01:00
fixed test cases errors
This commit is contained in:
@@ -87,6 +87,7 @@ export class IndexingPolicyComponent extends React.Component<
|
||||
private async createIndexingPolicyEditor(): Promise<void> {
|
||||
const value: string = JSON.stringify(this.props.indexingPolicyContent, undefined, 4);
|
||||
const monaco = await loadMonaco();
|
||||
if (monaco.editor) {
|
||||
this.indexingPolicyEditor = monaco.editor.create(this.indexingPolicyDiv.current, {
|
||||
value: value,
|
||||
language: "json",
|
||||
@@ -99,6 +100,7 @@ export class IndexingPolicyComponent extends React.Component<
|
||||
this.props.logIndexingPolicySuccessMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private onEditorContentChange = (): void => {
|
||||
const indexingPolicyEditorModel = this.indexingPolicyEditor.getModel();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as sinon from "sinon";
|
||||
import { D3ForceGraph, LoadMoreDataAction, D3GraphNodeData } from "./D3ForceGraph";
|
||||
import { D3Node, D3Link, GraphData } from "../GraphExplorerComponent/GraphData";
|
||||
import GraphTab from "../../Tabs/GraphTab";
|
||||
import { D3Link, D3Node, GraphData } from "../GraphExplorerComponent/GraphData";
|
||||
import { D3ForceGraph, D3GraphNodeData, LoadMoreDataAction } from "./D3ForceGraph";
|
||||
|
||||
describe("D3ForceGraph", () => {
|
||||
const v1Id = "v1";
|
||||
@@ -138,6 +138,7 @@ describe("D3ForceGraph", () => {
|
||||
|
||||
it("should call onHighlightedNode callback when mouse hovering over node", () => {
|
||||
forceGraph.params.onGraphUpdated = () => {
|
||||
if (document) {
|
||||
const mouseoverEvent = document.createEvent("Events");
|
||||
mouseoverEvent.initEvent("mouseover", true, false);
|
||||
$(rootNode).find(".node")[0].dispatchEvent(mouseoverEvent); // [0] is v1 vertex
|
||||
@@ -145,11 +146,12 @@ describe("D3ForceGraph", () => {
|
||||
// onHighlightedNode is always called once to clear the selection
|
||||
expect((forceGraph.params.onHighlightedNode as sinon.SinonSpy).calledTwice).toBe(true);
|
||||
|
||||
const onHighlightedNode = (forceGraph.params.onHighlightedNode as sinon.SinonSpy).args[1][0] as D3GraphNodeData;
|
||||
const onHighlightedNode = (forceGraph.params.onHighlightedNode as sinon.SinonSpy)
|
||||
.args[1][0] as D3GraphNodeData;
|
||||
expect(onHighlightedNode).not.toBe(null);
|
||||
expect(onHighlightedNode.id).toEqual(v1Id);
|
||||
}
|
||||
};
|
||||
|
||||
forceGraph.updateGraph(newGraph);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -626,12 +626,12 @@ export class D3ForceGraph implements GraphRenderer {
|
||||
|
||||
this.addNewLinks();
|
||||
|
||||
const nodes = this.simulation.nodes();
|
||||
const nodes = this.simulation && this.simulation.nodes();
|
||||
this.redrawGraph();
|
||||
|
||||
this.animateBigBang(nodes, newNodes);
|
||||
|
||||
this.simulation.alpha(1).restart();
|
||||
this.simulation && this.simulation.alpha(1).restart();
|
||||
this.params.onGraphUpdated(new Date().getTime());
|
||||
});
|
||||
|
||||
@@ -651,8 +651,9 @@ export class D3ForceGraph implements GraphRenderer {
|
||||
}
|
||||
|
||||
private addNewLinks(): d3.Selection<Element, any, any, any> {
|
||||
const newLinks = this.linkSelection.enter().append("g").attr("class", "markerEndContainer");
|
||||
|
||||
let newLinks: any = {};
|
||||
if (this.linkSelection) {
|
||||
newLinks = this.linkSelection.enter().append("g").attr("class", "markerEndContainer");
|
||||
const line = newLinks
|
||||
.append("path")
|
||||
.attr("class", "link")
|
||||
@@ -673,13 +674,15 @@ export class D3ForceGraph implements GraphRenderer {
|
||||
}
|
||||
|
||||
this.linkSelection = newLinks.merge(this.linkSelection);
|
||||
}
|
||||
return newLinks;
|
||||
}
|
||||
|
||||
private addNewNodes(): d3.Selection<Element, any, any, any> {
|
||||
var self = this;
|
||||
|
||||
const newNodes = this.nodeSelection
|
||||
let newNodes: any = {};
|
||||
if (this.nodeSelection) {
|
||||
newNodes = this.nodeSelection
|
||||
.enter()
|
||||
.append("g")
|
||||
.attr("class", (d: D3Node) => {
|
||||
@@ -784,7 +787,7 @@ export class D3ForceGraph implements GraphRenderer {
|
||||
});
|
||||
|
||||
this.nodeSelection = newNodes.merge(this.nodeSelection);
|
||||
|
||||
}
|
||||
return newNodes;
|
||||
}
|
||||
|
||||
@@ -967,6 +970,7 @@ export class D3ForceGraph implements GraphRenderer {
|
||||
* Remove LoadMore subassembly for existing nodes that show all their children in the graph
|
||||
*/
|
||||
private updateLoadMore(nodeSelection: d3.Selection<Element, any, any, any>) {
|
||||
if (nodeSelection) {
|
||||
const self = this;
|
||||
nodeSelection.selectAll(".loadmore").remove();
|
||||
|
||||
@@ -996,6 +1000,7 @@ export class D3ForceGraph implements GraphRenderer {
|
||||
// Don't color icons individually, just the definitions
|
||||
this.svg.selectAll("#loadMoreIcon ellipse").attr("fill", this.params.graphConfig.nodeColor());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load neighbors of this node
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import * as Q from "q";
|
||||
import * as sinon from "sinon";
|
||||
import * as DataModels from "../Contracts/DataModels";
|
||||
import * as ViewModels from "../Contracts/ViewModels";
|
||||
import * as QueryUtils from "./QueryUtils";
|
||||
|
||||
@@ -101,12 +101,16 @@ describe("Query Utils", () => {
|
||||
});
|
||||
|
||||
it("should not proceed with subsequent queries if the first one errors out", (done) => {
|
||||
try {
|
||||
const queryStub = sinon.stub().returns(Q.reject("Error injected for testing purposes"));
|
||||
QueryUtils.queryPagesUntilContentPresent(0, queryStub).finally(() => {
|
||||
expect(queryStub.callCount).toBe(1);
|
||||
expect(queryStub.getCall(0).args[0]).toBe(0);
|
||||
done();
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -176,12 +180,16 @@ describe("Query Utils", () => {
|
||||
});
|
||||
|
||||
it("should not proceed with subsequent fetches if the first one errors out", (done) => {
|
||||
try {
|
||||
const queryStub = sinon.stub().returns(Q.reject("Error injected for testing purposes"));
|
||||
QueryUtils.queryAllPages(queryStub).finally(() => {
|
||||
expect(queryStub.callCount).toBe(1);
|
||||
expect(queryStub.getCall(0).args[0]).toBe(0);
|
||||
done();
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,3 +16,12 @@ if (typeof window.URL.createObjectURL === "undefined") {
|
||||
require("jquery-ui-dist/jquery-ui");
|
||||
(<any>global).TextEncoder = TextEncoder;
|
||||
(<any>global).TextDecoder = TextDecoder;
|
||||
|
||||
// In Node v7 unhandled promise rejections
|
||||
if (process.env.LISTENING_TO_UNHANDLED_REJECTION !== "true") {
|
||||
process.on("unhandledRejection", (reason) => {
|
||||
console.error("reason", reason);
|
||||
});
|
||||
// Avoid memory leak by adding too many listeners
|
||||
process.env.LISTENING_TO_UNHANDLED_REJECTION = "true";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user