Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Malton <sebastian@malton.name>
  • Loading branch information
Nokel81 committed Mar 24, 2022
1 parent cef29fe commit 011183a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/main/catalog-sources/__test__/kubeconfig-sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ import { ClusterManager } from "../../cluster-manager";
import clusterStoreInjectable from "../../../common/cluster-store/cluster-store.injectable";
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
import { createClusterInjectionToken } from "../../../common/cluster/create-cluster-injection-token";
import directoryForKubeConfigsInjectable
from "../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";

import directoryForKubeConfigsInjectable from "../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
import { ClusterStore } from "../../../common/cluster-store/cluster-store";

jest.mock("electron", () => ({
app: {
Expand Down Expand Up @@ -57,6 +56,7 @@ describe("kubeconfig-sync.source tests", () => {
afterEach(() => {
mockFs.restore();
ClusterManager.resetInstance();
ClusterStore.resetInstance();
});

describe("configsToModels", () => {
Expand Down
5 changes: 3 additions & 2 deletions src/main/context-handler/create-context-handler.injectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ import type { Cluster } from "../../common/cluster/cluster";
import { ContextHandler } from "./context-handler";
import createKubeAuthProxyInjectable from "../kube-auth-proxy/create-kube-auth-proxy.injectable";
import { getKubeAuthProxyCertificate } from "../kube-auth-proxy/get-kube-auth-proxy-certificate";
import URLParse from "url-parse";

const createContextHandlerInjectable = getInjectable({
id: "create-context-handler",

instantiate: (di) => {
return (cluster: Cluster) => {
const clusterUrl = new URL(cluster.apiUrl);
const clusterUrl = new URLParse(cluster.apiUrl);

const dependencies = {
createKubeAuthProxy: di.inject(createKubeAuthProxyInjectable),
authProxyCa: getKubeAuthProxyCertificate(clusterUrl.hostname, selfsigned.generate).cert,
};

return new ContextHandler(dependencies, cluster);
};
},
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/components/dock/logs/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ const NonInjectedLogsDockTab = observer(({ className, tab, model, subscribeStore
setTimeout(() => {
const overlay = document.querySelector(".PodLogs .list span.active");

if (!overlay) return;
overlay.scrollIntoViewIfNeeded();
if (typeof overlay?.scrollIntoViewIfNeeded === "function") {
overlay.scrollIntoViewIfNeeded();
}
}, 100);
};

Expand Down
4 changes: 3 additions & 1 deletion src/renderer/components/tabs/tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ export class Tab extends React.PureComponent<TabProps> {
}

scrollIntoView() {
this.ref.current?.scrollIntoViewIfNeeded();
if (typeof this.ref.current?.scrollIntoViewIfNeeded === "function") {
this.ref.current.scrollIntoViewIfNeeded();
}
}

@boundMethod
Expand Down
2 changes: 1 addition & 1 deletion types/dom.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export {};

declare global {
interface Element {
scrollIntoViewIfNeeded(opt_center?: boolean): void;
scrollIntoViewIfNeeded?(opt_center?: boolean): void;
}

interface Window {
Expand Down

0 comments on commit 011183a

Please sign in to comment.