mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix hotbar-store tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
682d3211ce
commit
4733f3c4d0
@ -4,45 +4,61 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { anyObject } from "jest-mock-extended";
|
import { anyObject } from "jest-mock-extended";
|
||||||
import { merge } from "lodash";
|
|
||||||
import mockFs from "mock-fs";
|
import mockFs from "mock-fs";
|
||||||
import logger from "../../main/logger";
|
import logger from "../../main/logger";
|
||||||
import type { CatalogEntity, CatalogEntityData, CatalogEntityKindData } from "../catalog";
|
import type { CatalogEntity, CatalogEntityData, CatalogEntityKindData } from "../catalog";
|
||||||
import { HotbarStore } from "../hotbar-store";
|
import { HotbarStore } from "../hotbar-store";
|
||||||
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
|
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
|
||||||
import directoryForUserDataInjectable
|
import directoryForUserDataInjectable from "../app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
||||||
from "../app-paths/directory-for-user-data/directory-for-user-data.injectable";
|
|
||||||
|
|
||||||
jest.mock("../../main/catalog/catalog-entity-registry", () => ({
|
jest.mock("../../main/catalog/catalog-entity-registry", () => ({
|
||||||
catalogEntityRegistry: {
|
catalogEntityRegistry: {
|
||||||
items: [
|
items: [
|
||||||
{
|
getMockCatalogEntity({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Cluster",
|
||||||
|
status: {
|
||||||
|
phase: "Running",
|
||||||
|
},
|
||||||
metadata: {
|
metadata: {
|
||||||
uid: "1dfa26e2ebab15780a3547e9c7fa785c",
|
uid: "1dfa26e2ebab15780a3547e9c7fa785c",
|
||||||
name: "mycluster",
|
name: "mycluster",
|
||||||
source: "local",
|
source: "local",
|
||||||
|
labels: {},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
getMockCatalogEntity({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Cluster",
|
||||||
|
status: {
|
||||||
|
phase: "Running",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
|
||||||
metadata: {
|
metadata: {
|
||||||
uid: "55b42c3c7ba3b04193416cda405269a5",
|
uid: "55b42c3c7ba3b04193416cda405269a5",
|
||||||
name: "my_shiny_cluster",
|
name: "my_shiny_cluster",
|
||||||
source: "remote",
|
source: "remote",
|
||||||
|
labels: {},
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
getMockCatalogEntity({
|
||||||
|
apiVersion: "v1",
|
||||||
|
kind: "Cluster",
|
||||||
|
status: {
|
||||||
|
phase: "Running",
|
||||||
},
|
},
|
||||||
},
|
|
||||||
{
|
|
||||||
metadata: {
|
metadata: {
|
||||||
uid: "catalog-entity",
|
uid: "catalog-entity",
|
||||||
name: "Catalog",
|
name: "Catalog",
|
||||||
source: "app",
|
source: "app",
|
||||||
|
labels: {},
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function getMockCatalogEntity(data: Partial<CatalogEntityData> & CatalogEntityKindData): CatalogEntity {
|
function getMockCatalogEntity(data: Partial<CatalogEntityData> & CatalogEntityKindData): CatalogEntity {
|
||||||
return merge(data, {
|
return {
|
||||||
getName: jest.fn(() => data.metadata?.name),
|
getName: jest.fn(() => data.metadata?.name),
|
||||||
getId: jest.fn(() => data.metadata?.uid),
|
getId: jest.fn(() => data.metadata?.uid),
|
||||||
getSource: jest.fn(() => data.metadata?.source ?? "unknown"),
|
getSource: jest.fn(() => data.metadata?.source ?? "unknown"),
|
||||||
@ -52,7 +68,8 @@ function getMockCatalogEntity(data: Partial<CatalogEntityData> & CatalogEntityKi
|
|||||||
metadata: {},
|
metadata: {},
|
||||||
spec: {},
|
spec: {},
|
||||||
status: {},
|
status: {},
|
||||||
}) as CatalogEntity;
|
...data,
|
||||||
|
} as CatalogEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
const testCluster = getMockCatalogEntity({
|
const testCluster = getMockCatalogEntity({
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user