Remove OpenActionsStubs (#106)

This commit is contained in:
Steve Faulkner
2020-07-21 13:50:51 -05:00
committed by GitHub
parent 46cca859e3
commit 4f86015be7
29 changed files with 157 additions and 681 deletions

View File

@@ -1,7 +1,6 @@
import * as ko from "knockout";
import { handleOpenAction } from "./OpenActions";
import * as ViewModels from "../Contracts/ViewModels";
import { DatabaseStub, CollectionStub } from "./OpenActionsStubs";
import { ActionContracts } from "../Contracts/ExplorerContracts";
import Explorer from "./Explorer";
import CassandraAddCollectionPane from "./Panes/CassandraAddCollectionPane";
@@ -14,14 +13,6 @@ describe("OpenActions", () => {
let collection: ViewModels.Collection;
let databases: ViewModels.Database[];
let expandCollection: jasmine.Spy;
let onDocumentDBDocumentsClick: jasmine.Spy;
let onMongoDBDocumentsClick: jasmine.Spy;
let onTableEntitiesClick: jasmine.Spy;
let onGraphDocumentsClick: jasmine.Spy;
let onNewQueryClick: jasmine.Spy;
let onSettingsClick: jasmine.Spy;
beforeEach(() => {
explorer = {} as Explorer;
explorer.addCollectionPane = {} as AddCollectionPane;
@@ -31,22 +22,22 @@ describe("OpenActions", () => {
explorer.closeAllPanes = () => {};
explorer.isConnectExplorerVisible = () => false;
database = new DatabaseStub({
database = {
id: ko.observable("db"),
collections: ko.observableArray<ViewModels.Collection>([])
});
} as ViewModels.Database;
databases = [database];
collection = new CollectionStub({
collection = {
id: ko.observable("coll")
});
} as ViewModels.Collection;
expandCollection = spyOn(collection, "expandCollection");
onDocumentDBDocumentsClick = spyOn(collection, "onDocumentDBDocumentsClick");
onMongoDBDocumentsClick = spyOn(collection, "onMongoDBDocumentsClick");
onTableEntitiesClick = spyOn(collection, "onTableEntitiesClick");
onGraphDocumentsClick = spyOn(collection, "onGraphDocumentsClick");
onNewQueryClick = spyOn(collection, "onNewQueryClick");
onSettingsClick = spyOn(collection, "onSettingsClick");
collection.expandCollection = jest.fn();
collection.onDocumentDBDocumentsClick = jest.fn();
collection.onMongoDBDocumentsClick = jest.fn();
collection.onTableEntitiesClick = jest.fn();
collection.onGraphDocumentsClick = jest.fn();
collection.onNewQueryClick = jest.fn();
collection.onSettingsClick = jest.fn();
});
describe("unknown action type", () => {
@@ -146,10 +137,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(expandCollection).not.toHaveBeenCalled();
expect(collection.expandCollection).not.toHaveBeenCalled();
database.collections([collection]);
expect(expandCollection).toHaveBeenCalled();
expect(collection.expandCollection).toHaveBeenCalled();
});
it("should expand collection node when handleOpenAction is called", () => {
@@ -161,7 +152,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(expandCollection).toHaveBeenCalled();
expect(collection.expandCollection).toHaveBeenCalled();
});
describe("SQLDocuments tab kind", () => {
@@ -174,10 +165,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onDocumentDBDocumentsClick).not.toHaveBeenCalled();
expect(collection.onDocumentDBDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onDocumentDBDocumentsClick).toHaveBeenCalled();
expect(collection.onDocumentDBDocumentsClick).toHaveBeenCalled();
});
it("string value should call onDocumentDBDocumentsClick", () => {
@@ -190,7 +181,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onDocumentDBDocumentsClick).toHaveBeenCalled();
expect(collection.onDocumentDBDocumentsClick).toHaveBeenCalled();
});
it("enum value should call onDocumentDBDocumentsClick before collections are fetched", () => {
@@ -202,10 +193,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onDocumentDBDocumentsClick).not.toHaveBeenCalled();
expect(collection.onDocumentDBDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onDocumentDBDocumentsClick).toHaveBeenCalled();
expect(collection.onDocumentDBDocumentsClick).toHaveBeenCalled();
});
it("enum value should call onDocumentDBDocumentsClick", () => {
@@ -218,7 +209,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onDocumentDBDocumentsClick).toHaveBeenCalled();
expect(collection.onDocumentDBDocumentsClick).toHaveBeenCalled();
});
});
@@ -232,10 +223,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onMongoDBDocumentsClick).not.toHaveBeenCalled();
expect(collection.onMongoDBDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onMongoDBDocumentsClick).toHaveBeenCalled();
expect(collection.onMongoDBDocumentsClick).toHaveBeenCalled();
});
it("string value should call onMongoDBDocumentsClick", () => {
@@ -248,7 +239,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onMongoDBDocumentsClick).toHaveBeenCalled();
expect(collection.onMongoDBDocumentsClick).toHaveBeenCalled();
});
it("enum value should call onMongoDBDocumentsClick before collections are fetched", () => {
@@ -260,10 +251,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onMongoDBDocumentsClick).not.toHaveBeenCalled();
expect(collection.onMongoDBDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onMongoDBDocumentsClick).toHaveBeenCalled();
expect(collection.onMongoDBDocumentsClick).toHaveBeenCalled();
});
it("enum value should call onMongoDBDocumentsClick", () => {
@@ -276,7 +267,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onMongoDBDocumentsClick).toHaveBeenCalled();
expect(collection.onMongoDBDocumentsClick).toHaveBeenCalled();
});
});
@@ -290,10 +281,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onTableEntitiesClick).not.toHaveBeenCalled();
expect(collection.onTableEntitiesClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onTableEntitiesClick).toHaveBeenCalled();
expect(collection.onTableEntitiesClick).toHaveBeenCalled();
});
it("string value should call onTableEntitiesClick", () => {
@@ -306,7 +297,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onTableEntitiesClick).toHaveBeenCalled();
expect(collection.onTableEntitiesClick).toHaveBeenCalled();
});
it("enum value should call onTableEntitiesClick before collections are fetched", () => {
@@ -319,7 +310,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onTableEntitiesClick).toHaveBeenCalled();
expect(collection.onTableEntitiesClick).toHaveBeenCalled();
});
it("enum value should call onTableEntitiesClick", () => {
@@ -331,10 +322,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onTableEntitiesClick).not.toHaveBeenCalled();
expect(collection.onTableEntitiesClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onTableEntitiesClick).toHaveBeenCalled();
expect(collection.onTableEntitiesClick).toHaveBeenCalled();
});
});
@@ -348,10 +339,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onGraphDocumentsClick).not.toHaveBeenCalled();
expect(collection.onGraphDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onGraphDocumentsClick).toHaveBeenCalled();
expect(collection.onGraphDocumentsClick).toHaveBeenCalled();
});
it("string value should call onGraphDocumentsClick", () => {
@@ -364,7 +355,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onGraphDocumentsClick).toHaveBeenCalled();
expect(collection.onGraphDocumentsClick).toHaveBeenCalled();
});
it("enum value should call onGraphDocumentsClick before collections are fetched", () => {
@@ -376,10 +367,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onGraphDocumentsClick).not.toHaveBeenCalled();
expect(collection.onGraphDocumentsClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onGraphDocumentsClick).toHaveBeenCalled();
expect(collection.onGraphDocumentsClick).toHaveBeenCalled();
});
it("enum value should call onGraphDocumentsClick", () => {
@@ -392,7 +383,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onGraphDocumentsClick).toHaveBeenCalled();
expect(collection.onGraphDocumentsClick).toHaveBeenCalled();
});
});
@@ -406,10 +397,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onNewQueryClick).not.toHaveBeenCalled();
expect(collection.onNewQueryClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onNewQueryClick).toHaveBeenCalled();
expect(collection.onNewQueryClick).toHaveBeenCalled();
});
it("string value should call onNewQueryClick", () => {
@@ -422,7 +413,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onNewQueryClick).toHaveBeenCalled();
expect(collection.onNewQueryClick).toHaveBeenCalled();
});
it("enum value should call onNewQueryClick before collections are fetched", () => {
@@ -434,10 +425,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onNewQueryClick).not.toHaveBeenCalled();
expect(collection.onNewQueryClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onNewQueryClick).toHaveBeenCalled();
expect(collection.onNewQueryClick).toHaveBeenCalled();
});
it("enum value should call onNewQueryClick", () => {
@@ -450,7 +441,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onNewQueryClick).toHaveBeenCalled();
expect(collection.onNewQueryClick).toHaveBeenCalled();
});
});
@@ -464,10 +455,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onSettingsClick).not.toHaveBeenCalled();
expect(collection.onSettingsClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onSettingsClick).toHaveBeenCalled();
expect(collection.onSettingsClick).toHaveBeenCalled();
});
it("string value should call onSettingsClick", () => {
@@ -480,7 +471,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onSettingsClick).toHaveBeenCalled();
expect(collection.onSettingsClick).toHaveBeenCalled();
});
it("enum value should call onSettingsClick before collections are fetched", () => {
@@ -492,10 +483,10 @@ describe("OpenActions", () => {
};
handleOpenAction(action, [database], explorer);
expect(onSettingsClick).not.toHaveBeenCalled();
expect(collection.onSettingsClick).not.toHaveBeenCalled();
database.collections([collection]);
expect(onSettingsClick).toHaveBeenCalled();
expect(collection.onSettingsClick).toHaveBeenCalled();
});
it("enum value should call onSettingsClick", () => {
@@ -508,7 +499,7 @@ describe("OpenActions", () => {
database.collections([collection]);
handleOpenAction(action, [database], explorer);
expect(onSettingsClick).toHaveBeenCalled();
expect(collection.onSettingsClick).toHaveBeenCalled();
});
});
});