mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Move mocked vars into beforeEach()
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
209a18e59a
commit
0b9118cfb4
@ -12,6 +12,9 @@ import directoryForUserDataInjectable from "../../../common/app-paths/directory-
|
|||||||
import type { Fetch } from "../../../common/fetch/fetch.injectable";
|
import type { Fetch } from "../../../common/fetch/fetch.injectable";
|
||||||
import fetchInjectable from "../../../common/fetch/fetch.injectable";
|
import fetchInjectable from "../../../common/fetch/fetch.injectable";
|
||||||
import { Namespace, NamespaceApi } from "../../../common/k8s-api/endpoints";
|
import { Namespace, NamespaceApi } from "../../../common/k8s-api/endpoints";
|
||||||
|
import type { DeleteResourceDescriptor } from "../../../common/k8s-api/kube-api";
|
||||||
|
import type { KubeJsonApiData } from "../../../common/k8s-api/kube-json-api";
|
||||||
|
import type { KubeJsonApiObjectMetadata, KubeObjectScope } from "../../../common/k8s-api/kube-object";
|
||||||
import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable";
|
import hostedClusterInjectable from "../../cluster-frame-context/hosted-cluster.injectable";
|
||||||
import createClusterInjectable from "../../cluster/create-cluster.injectable";
|
import createClusterInjectable from "../../cluster/create-cluster.injectable";
|
||||||
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
||||||
@ -106,15 +109,12 @@ const levelDeepSubChildA = createNamespace("level-deep-subchild-a", {
|
|||||||
"level-deep-subchild-a.tree.hnc.x-k8s.io/depth": "0",
|
"level-deep-subchild-a.tree.hnc.x-k8s.io/depth": "0",
|
||||||
});
|
});
|
||||||
|
|
||||||
const deleteNamespaceMock = jest.spyOn(NamespaceApi.prototype, "delete")
|
|
||||||
.mockImplementation();
|
|
||||||
|
|
||||||
const removeSubnamespaceMock = jest.fn();
|
|
||||||
|
|
||||||
describe("NamespaceStore", () => {
|
describe("NamespaceStore", () => {
|
||||||
let di: DiContainer;
|
let di: DiContainer;
|
||||||
let namespaceStore: NamespaceStore;
|
let namespaceStore: NamespaceStore;
|
||||||
let fetchMock: AsyncFnMock<Fetch>;
|
let fetchMock: AsyncFnMock<Fetch>;
|
||||||
|
let deleteNamespaceMock: jest.SpyInstance<Promise<KubeJsonApiData<KubeJsonApiObjectMetadata<KubeObjectScope>, unknown, unknown>>, [DeleteResourceDescriptor]>
|
||||||
|
let removeSubnamespaceMock: jest.Mock<any, any>
|
||||||
|
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
@ -126,6 +126,9 @@ describe("NamespaceStore", () => {
|
|||||||
di.override(storesAndApisCanBeCreatedInjectable, () => true);
|
di.override(storesAndApisCanBeCreatedInjectable, () => true);
|
||||||
di.override(removeSubnamespaceInjectable, () => removeSubnamespaceMock);
|
di.override(removeSubnamespaceInjectable, () => removeSubnamespaceMock);
|
||||||
|
|
||||||
|
deleteNamespaceMock = jest.spyOn(NamespaceApi.prototype, "delete").mockImplementation();
|
||||||
|
removeSubnamespaceMock = jest.fn();
|
||||||
|
|
||||||
const createCluster = di.inject(createClusterInjectable);
|
const createCluster = di.inject(createClusterInjectable);
|
||||||
|
|
||||||
di.override(hostedClusterInjectable, () => createCluster({
|
di.override(hostedClusterInjectable, () => createCluster({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user