mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix unit tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
cef29fe708
commit
011183a825
@ -14,9 +14,8 @@ import { ClusterManager } from "../../cluster-manager";
|
|||||||
import clusterStoreInjectable from "../../../common/cluster-store/cluster-store.injectable";
|
import clusterStoreInjectable from "../../../common/cluster-store/cluster-store.injectable";
|
||||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||||
import { createClusterInjectionToken } from "../../../common/cluster/create-cluster-injection-token";
|
import { createClusterInjectionToken } from "../../../common/cluster/create-cluster-injection-token";
|
||||||
import directoryForKubeConfigsInjectable
|
import directoryForKubeConfigsInjectable from "../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
|
||||||
from "../../../common/app-paths/directory-for-kube-configs/directory-for-kube-configs.injectable";
|
import { ClusterStore } from "../../../common/cluster-store/cluster-store";
|
||||||
|
|
||||||
|
|
||||||
jest.mock("electron", () => ({
|
jest.mock("electron", () => ({
|
||||||
app: {
|
app: {
|
||||||
@ -57,6 +56,7 @@ describe("kubeconfig-sync.source tests", () => {
|
|||||||
afterEach(() => {
|
afterEach(() => {
|
||||||
mockFs.restore();
|
mockFs.restore();
|
||||||
ClusterManager.resetInstance();
|
ClusterManager.resetInstance();
|
||||||
|
ClusterStore.resetInstance();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("configsToModels", () => {
|
describe("configsToModels", () => {
|
||||||
|
|||||||
@ -8,19 +8,20 @@ import type { Cluster } from "../../common/cluster/cluster";
|
|||||||
import { ContextHandler } from "./context-handler";
|
import { ContextHandler } from "./context-handler";
|
||||||
import createKubeAuthProxyInjectable from "../kube-auth-proxy/create-kube-auth-proxy.injectable";
|
import createKubeAuthProxyInjectable from "../kube-auth-proxy/create-kube-auth-proxy.injectable";
|
||||||
import { getKubeAuthProxyCertificate } from "../kube-auth-proxy/get-kube-auth-proxy-certificate";
|
import { getKubeAuthProxyCertificate } from "../kube-auth-proxy/get-kube-auth-proxy-certificate";
|
||||||
|
import URLParse from "url-parse";
|
||||||
|
|
||||||
const createContextHandlerInjectable = getInjectable({
|
const createContextHandlerInjectable = getInjectable({
|
||||||
id: "create-context-handler",
|
id: "create-context-handler",
|
||||||
|
|
||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
return (cluster: Cluster) => {
|
return (cluster: Cluster) => {
|
||||||
const clusterUrl = new URL(cluster.apiUrl);
|
const clusterUrl = new URLParse(cluster.apiUrl);
|
||||||
|
|
||||||
const dependencies = {
|
const dependencies = {
|
||||||
createKubeAuthProxy: di.inject(createKubeAuthProxyInjectable),
|
createKubeAuthProxy: di.inject(createKubeAuthProxyInjectable),
|
||||||
authProxyCa: getKubeAuthProxyCertificate(clusterUrl.hostname, selfsigned.generate).cert,
|
authProxyCa: getKubeAuthProxyCertificate(clusterUrl.hostname, selfsigned.generate).cert,
|
||||||
};
|
};
|
||||||
|
|
||||||
return new ContextHandler(dependencies, cluster);
|
return new ContextHandler(dependencies, cluster);
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@ -57,8 +57,9 @@ const NonInjectedLogsDockTab = observer(({ className, tab, model, subscribeStore
|
|||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
const overlay = document.querySelector(".PodLogs .list span.active");
|
const overlay = document.querySelector(".PodLogs .list span.active");
|
||||||
|
|
||||||
if (!overlay) return;
|
if (typeof overlay?.scrollIntoViewIfNeeded === "function") {
|
||||||
overlay.scrollIntoViewIfNeeded();
|
overlay.scrollIntoViewIfNeeded();
|
||||||
|
}
|
||||||
}, 100);
|
}, 100);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -81,7 +81,9 @@ export class Tab extends React.PureComponent<TabProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
scrollIntoView() {
|
scrollIntoView() {
|
||||||
this.ref.current?.scrollIntoViewIfNeeded();
|
if (typeof this.ref.current?.scrollIntoViewIfNeeded === "function") {
|
||||||
|
this.ref.current.scrollIntoViewIfNeeded();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@boundMethod
|
@boundMethod
|
||||||
|
|||||||
2
types/dom.d.ts
vendored
2
types/dom.d.ts
vendored
@ -6,7 +6,7 @@ export {};
|
|||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Element {
|
interface Element {
|
||||||
scrollIntoViewIfNeeded(opt_center?: boolean): void;
|
scrollIntoViewIfNeeded?(opt_center?: boolean): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Window {
|
interface Window {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user