mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
47ddec78cd
commit
992560357f
@ -8,6 +8,7 @@ import { catalogCategoryRegistry } from "../../../common/catalog/catalog-categor
|
|||||||
import { CatalogCategory, CatalogEntityData, CatalogEntityKindData } from "../catalog-entity";
|
import { CatalogCategory, CatalogEntityData, CatalogEntityKindData } from "../catalog-entity";
|
||||||
import { KubernetesCluster, WebLink } from "../../../common/catalog-entities";
|
import { KubernetesCluster, WebLink } from "../../../common/catalog-entities";
|
||||||
import { observable, runInAction } from "mobx";
|
import { observable, runInAction } from "mobx";
|
||||||
|
import { noop } from "../../utils";
|
||||||
|
|
||||||
class TestCatalogEntityRegistry extends CatalogEntityRegistry {
|
class TestCatalogEntityRegistry extends CatalogEntityRegistry {
|
||||||
replaceItems(items: (CatalogEntityData & CatalogEntityKindData)[]) {
|
replaceItems(items: (CatalogEntityData & CatalogEntityKindData)[]) {
|
||||||
@ -88,7 +89,10 @@ const entitykc = new KubernetesCluster({
|
|||||||
describe("CatalogEntityRegistry", () => {
|
describe("CatalogEntityRegistry", () => {
|
||||||
describe("updateItems", () => {
|
describe("updateItems", () => {
|
||||||
it("adds new catalog item", () => {
|
it("adds new catalog item", () => {
|
||||||
const catalog = new TestCatalogEntityRegistry(catalogCategoryRegistry);
|
const catalog = new TestCatalogEntityRegistry({
|
||||||
|
categoryRegistry: catalogCategoryRegistry,
|
||||||
|
initSync: noop,
|
||||||
|
});
|
||||||
const items = [{
|
const items = [{
|
||||||
apiVersion: "entity.k8slens.dev/v1alpha1",
|
apiVersion: "entity.k8slens.dev/v1alpha1",
|
||||||
kind: "KubernetesCluster",
|
kind: "KubernetesCluster",
|
||||||
@ -127,7 +131,10 @@ describe("CatalogEntityRegistry", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("updates existing items", () => {
|
it("updates existing items", () => {
|
||||||
const catalog = new TestCatalogEntityRegistry(catalogCategoryRegistry);
|
const catalog = new TestCatalogEntityRegistry({
|
||||||
|
categoryRegistry: catalogCategoryRegistry,
|
||||||
|
initSync: noop,
|
||||||
|
});
|
||||||
const items = [{
|
const items = [{
|
||||||
apiVersion: "entity.k8slens.dev/v1alpha1",
|
apiVersion: "entity.k8slens.dev/v1alpha1",
|
||||||
kind: "KubernetesCluster",
|
kind: "KubernetesCluster",
|
||||||
@ -155,7 +162,10 @@ describe("CatalogEntityRegistry", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("updates activeEntity", () => {
|
it("updates activeEntity", () => {
|
||||||
const catalog = new TestCatalogEntityRegistry(catalogCategoryRegistry);
|
const catalog = new TestCatalogEntityRegistry({
|
||||||
|
categoryRegistry: catalogCategoryRegistry,
|
||||||
|
initSync: noop,
|
||||||
|
});
|
||||||
const items = [{
|
const items = [{
|
||||||
apiVersion: "entity.k8slens.dev/v1alpha1",
|
apiVersion: "entity.k8slens.dev/v1alpha1",
|
||||||
kind: "KubernetesCluster",
|
kind: "KubernetesCluster",
|
||||||
@ -181,7 +191,10 @@ describe("CatalogEntityRegistry", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("removes deleted items", () => {
|
it("removes deleted items", () => {
|
||||||
const catalog = new TestCatalogEntityRegistry(catalogCategoryRegistry);
|
const catalog = new TestCatalogEntityRegistry({
|
||||||
|
categoryRegistry: catalogCategoryRegistry,
|
||||||
|
initSync: noop,
|
||||||
|
});
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
apiVersion: "entity.k8slens.dev/v1alpha1",
|
apiVersion: "entity.k8slens.dev/v1alpha1",
|
||||||
@ -223,7 +236,10 @@ describe("CatalogEntityRegistry", () => {
|
|||||||
|
|
||||||
describe("items", () => {
|
describe("items", () => {
|
||||||
it("does not return items without matching category", () => {
|
it("does not return items without matching category", () => {
|
||||||
const catalog = new TestCatalogEntityRegistry(catalogCategoryRegistry);
|
const catalog = new TestCatalogEntityRegistry({
|
||||||
|
categoryRegistry: catalogCategoryRegistry,
|
||||||
|
initSync: noop,
|
||||||
|
});
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
apiVersion: "entity.k8slens.dev/v1alpha1",
|
apiVersion: "entity.k8slens.dev/v1alpha1",
|
||||||
@ -261,7 +277,10 @@ describe("CatalogEntityRegistry", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does return items after matching category is added", () => {
|
it("does return items after matching category is added", () => {
|
||||||
const catalog = new TestCatalogEntityRegistry(catalogCategoryRegistry);
|
const catalog = new TestCatalogEntityRegistry({
|
||||||
|
categoryRegistry: catalogCategoryRegistry,
|
||||||
|
initSync: noop,
|
||||||
|
});
|
||||||
const items = [
|
const items = [
|
||||||
{
|
{
|
||||||
apiVersion: "entity.k8slens.dev/v1alpha1",
|
apiVersion: "entity.k8slens.dev/v1alpha1",
|
||||||
@ -286,7 +305,10 @@ describe("CatalogEntityRegistry", () => {
|
|||||||
|
|
||||||
it("does not return items that are filtered out", () => {
|
it("does not return items that are filtered out", () => {
|
||||||
const source = observable.array([entity, entity2, entitykc]);
|
const source = observable.array([entity, entity2, entitykc]);
|
||||||
const catalog = new TestCatalogEntityRegistry(catalogCategoryRegistry);
|
const catalog = new TestCatalogEntityRegistry({
|
||||||
|
categoryRegistry: catalogCategoryRegistry,
|
||||||
|
initSync: noop,
|
||||||
|
});
|
||||||
|
|
||||||
catalog.replaceItems(source);
|
catalog.replaceItems(source);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user