From 0aa3cecddfb201865d58811f0c3bb45026474509 Mon Sep 17 00:00:00 2001 From: Vincenzo Scamporlino Date: Mon, 9 Oct 2023 14:13:44 +0200 Subject: [PATCH] catalog: simplify typings Signed-off-by: Vincenzo Scamporlino --- .../CatalogPage/DefaultCatalogPage.test.tsx | 60 ++++++++----------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx index b331c0e477..53f031e263 100644 --- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx +++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx @@ -117,43 +117,31 @@ describe('DefaultCatalogPage', () => { ], }, })), - queryEntities: jest.fn().mockImplementation(async request => { - if ( - ( - (request as QueryEntitiesInitialRequest).filter as Record< - string, - string - > - )['relations.ownedBy'] - ) { - // owned entities - return { items: [], totalItems: 3, pageInfo: {} }; - } + queryEntities: jest + .fn() + .mockImplementation(async (request: QueryEntitiesInitialRequest) => { + if ((request.filter as any)['relations.ownedBy']) { + // owned entities + return { items: [], totalItems: 3, pageInfo: {} }; + } - if ( - ( - (request as QueryEntitiesInitialRequest).filter as Record< - string, - string - > - )['metadata.name'] - ) { - // starred entities - return { - items: [ - { - apiVersion: '1', - kind: 'component', - metadata: { name: 'Entity1', namespace: 'default' }, - }, - ], - totalItems: 1, - pageInfo: {}, - }; - } - // all items - return { items: [], totalItems: 2, pageInfo: {} }; - }), + if ((request.filter as any)['metadata.name']) { + // starred entities + return { + items: [ + { + apiVersion: '1', + kind: 'component', + metadata: { name: 'Entity1', namespace: 'default' }, + }, + ], + totalItems: 1, + pageInfo: {}, + }; + } + // all items + return { items: [], totalItems: 2, pageInfo: {} }; + }), }; const testProfile: Partial = {