1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add 'can mutate entity' to catalog-entity-registry.test.ts

Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
Hung-Han (Henry) Chen 2021-10-11 17:04:14 +03:00
parent b2b3c44695
commit 95d152936a
No known key found for this signature in database
GPG Key ID: 54B44603D251B788

View File

@ -92,6 +92,38 @@ describe("CatalogEntityRegistry", () => {
expect(registry.items.length).toEqual(1);
});
it ("can mutate entity", () => {
const source = observable.array([]);
registry.addObservableSource("test", source);
source.push(entity);
const index = source.findIndex((i) => i.metadata.uid === entity.metadata.uid);
const updateEntity = new WebLink({
metadata: {
uid: "test",
name: "test-link",
source: "test",
labels: {}
},
spec: {
url: "https://k8slens.dev"
},
status: {
phase: "unavailable"
}
});
source.splice(index, 1, updateEntity);
expect(registry.items.length).toEqual(1);
const found = registry.items.find((i) => i.metadata.uid === updateEntity.metadata.uid);
expect(found).toBeDefined();
expect(found.status.phase).toBe("unavailable");
});
it ("added source change triggers reaction", (done) => {
const source = observable.array([]);