mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Explicitly initialize registries
- Helps moves towards turning on banning CyclicImports Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
1 parent
c18df6bcae
commit
6d10f011e5
101 files changed
+1178
-1087
No files matched your search
@@ -30,10 +30,17 @@ jest.mock("electron", () => ({
|
||||
}));
|
||||
|
||||
import { BottomBar } from "./bottom-bar";
|
||||
jest.mock("../../../extensions/registries");
|
||||
import { statusBarRegistry } from "../../../extensions/registries";
|
||||
import { StatusBarRegistry } from "../../../extensions/registries";
|
||||
|
||||
describe("<BottomBar />", () => {
|
||||
beforeEach(() => {
|
||||
StatusBarRegistry.createInstance();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
StatusBarRegistry.resetInstance();
|
||||
});
|
||||
|
||||
it("renders w/o errors", () => {
|
||||
const { container } = render(<BottomBar />);
|
||||
|
||||
@@ -41,19 +48,19 @@ describe("<BottomBar />", () => {
|
||||
});
|
||||
|
||||
it("renders w/o errors when .getItems() returns unexpected (not type complient) data", async () => {
|
||||
statusBarRegistry.getItems = jest.fn().mockImplementationOnce(() => undefined);
|
||||
StatusBarRegistry.getInstance().getItems = jest.fn().mockImplementationOnce(() => undefined);
|
||||
expect(() => render(<BottomBar />)).not.toThrow();
|
||||
statusBarRegistry.getItems = jest.fn().mockImplementationOnce(() => "hello");
|
||||
StatusBarRegistry.getInstance().getItems = jest.fn().mockImplementationOnce(() => "hello");
|
||||
expect(() => render(<BottomBar />)).not.toThrow();
|
||||
statusBarRegistry.getItems = jest.fn().mockImplementationOnce(() => 6);
|
||||
StatusBarRegistry.getInstance().getItems = jest.fn().mockImplementationOnce(() => 6);
|
||||
expect(() => render(<BottomBar />)).not.toThrow();
|
||||
statusBarRegistry.getItems = jest.fn().mockImplementationOnce(() => null);
|
||||
StatusBarRegistry.getInstance().getItems = jest.fn().mockImplementationOnce(() => null);
|
||||
expect(() => render(<BottomBar />)).not.toThrow();
|
||||
statusBarRegistry.getItems = jest.fn().mockImplementationOnce(() => []);
|
||||
StatusBarRegistry.getInstance().getItems = jest.fn().mockImplementationOnce(() => []);
|
||||
expect(() => render(<BottomBar />)).not.toThrow();
|
||||
statusBarRegistry.getItems = jest.fn().mockImplementationOnce(() => [{}]);
|
||||
StatusBarRegistry.getInstance().getItems = jest.fn().mockImplementationOnce(() => [{}]);
|
||||
expect(() => render(<BottomBar />)).not.toThrow();
|
||||
statusBarRegistry.getItems = jest.fn().mockImplementationOnce(() => { return {};});
|
||||
StatusBarRegistry.getInstance().getItems = jest.fn().mockImplementationOnce(() => { return {};});
|
||||
expect(() => render(<BottomBar />)).not.toThrow();
|
||||
});
|
||||
|
||||
@@ -61,7 +68,7 @@ describe("<BottomBar />", () => {
|
||||
const testId = "testId";
|
||||
const text = "heee";
|
||||
|
||||
statusBarRegistry.getItems = jest.fn().mockImplementationOnce(() => [
|
||||
StatusBarRegistry.getInstance().getItems = jest.fn().mockImplementationOnce(() => [
|
||||
{ item: <span data-testid={testId} >{text}</span> }
|
||||
]);
|
||||
const { getByTestId } = render(<BottomBar />);
|
||||
@@ -73,7 +80,7 @@ describe("<BottomBar />", () => {
|
||||
const testId = "testId";
|
||||
const text = "heee";
|
||||
|
||||
statusBarRegistry.getItems = jest.fn().mockImplementationOnce(() => [
|
||||
StatusBarRegistry.getInstance().getItems = jest.fn().mockImplementationOnce(() => [
|
||||
{ item: () => <span data-testid={testId} >{text}</span> }
|
||||
]);
|
||||
const { getByTestId } = render(<BottomBar />);
|
||||
|
||||
@@ -23,7 +23,7 @@ import "./bottom-bar.scss";
|
||||
|
||||
import React from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { StatusBarRegistration, statusBarRegistry } from "../../../extensions/registries";
|
||||
import { StatusBarRegistration, StatusBarRegistry } from "../../../extensions/registries";
|
||||
import { navigate } from "../../navigation";
|
||||
import { Icon } from "../icon";
|
||||
import { catalogURL } from "../../../common/routes";
|
||||
@@ -41,7 +41,7 @@ export class BottomBar extends React.Component {
|
||||
}
|
||||
|
||||
renderRegisteredItems() {
|
||||
const items = statusBarRegistry.getItems();
|
||||
const items = StatusBarRegistry.getInstance().getItems();
|
||||
|
||||
if (!Array.isArray(items)) {
|
||||
return null;
|
||||
|
||||
@@ -29,7 +29,7 @@ import { Catalog } from "../+catalog";
|
||||
import { Preferences } from "../+preferences";
|
||||
import { AddCluster } from "../+add-cluster";
|
||||
import { ClusterView } from "./cluster-view";
|
||||
import { globalPageRegistry } from "../../../extensions/registries/page-registry";
|
||||
import { GlobalPageRegistry } from "../../../extensions/registries/page-registry";
|
||||
import { Extensions } from "../+extensions";
|
||||
import { HotbarMenu } from "../hotbar/hotbar-menu";
|
||||
import { EntitySettings } from "../+entity-settings";
|
||||
@@ -52,7 +52,7 @@ export class ClusterManager extends React.Component {
|
||||
<Route component={ClusterView} {...routes.clusterViewRoute} />
|
||||
<Route component={EntitySettings} {...routes.entitySettingsRoute} />
|
||||
{
|
||||
globalPageRegistry.getItems()
|
||||
GlobalPageRegistry.getInstance().getItems()
|
||||
.map(({ url, components: { Page } }) => (
|
||||
<Route key={url} path={url} component={Page} />
|
||||
))
|
||||
|
||||
Reference in new issue
Block a user