From d79f104234830d13f843c38342fee738d83bc806 Mon Sep 17 00:00:00 2001 From: Eric Peterson Date: Thu, 13 Oct 2022 15:17:27 +0200 Subject: [PATCH] Fix entity mocks in tests Signed-off-by: Eric Peterson --- .../components/EntityBadgesDialog.test.tsx | 5 ++++- .../EntityLinksCard/EntityLinksCard.test.tsx | 2 ++ .../EntitySwitch/EntitySwitch.test.tsx | 20 ++++++++++++------- .../GoCdBuildsComponent.test.tsx | 4 +++- .../src/components/TodoList/TodoList.test.tsx | 5 ++++- 5 files changed, 26 insertions(+), 10 deletions(-) diff --git a/plugins/badges/src/components/EntityBadgesDialog.test.tsx b/plugins/badges/src/components/EntityBadgesDialog.test.tsx index ea44eb20fc..5d0e7fe849 100644 --- a/plugins/badges/src/components/EntityBadgesDialog.test.tsx +++ b/plugins/badges/src/components/EntityBadgesDialog.test.tsx @@ -38,7 +38,10 @@ describe('EntityBadgesDialog', () => { }, ]), }; - const mockEntity = { metadata: { name: 'mock' } } as Entity; + const mockEntity = { + metadata: { name: 'mock' }, + kind: 'MockKind', + } as Entity; const rendered = await renderWithEffects( { const createEntity = (links: EntityLink[] = []): Entity => ({ metadata: { + name: 'mock', links, }, + kind: 'MockKind', } as Entity); const createLink = ({ diff --git a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx index 9588327c3b..4ee9d9c820 100644 --- a/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx +++ b/plugins/catalog/src/components/EntitySwitch/EntitySwitch.test.tsx @@ -46,7 +46,9 @@ describe('EntitySwitch', () => { const rendered = render( - + {content} , @@ -58,7 +60,9 @@ describe('EntitySwitch', () => { rendered.rerender( - + {content} , @@ -70,7 +74,9 @@ describe('EntitySwitch', () => { rendered.rerender( - + {content} , @@ -94,7 +100,7 @@ describe('EntitySwitch', () => { }); it('should switch child when filters switch', () => { - const entity = { kind: 'component' } as Entity; + const entity = { metadata: { name: 'mock' }, kind: 'component' } as Entity; const rendered = render( @@ -126,7 +132,7 @@ describe('EntitySwitch', () => { }); it('should switch with async condition that is true', async () => { - const entity = { kind: 'component' } as Entity; + const entity = { metadata: { name: 'mock' }, kind: 'component' } as Entity; const shouldRender = () => Promise.resolve(true); const rendered = render( @@ -145,7 +151,7 @@ describe('EntitySwitch', () => { }); it('should switch with sync condition that is false', async () => { - const entity = { kind: 'component' } as Entity; + const entity = { metadata: { name: 'mock' }, kind: 'component' } as Entity; const shouldRender = () => Promise.resolve(false); const rendered = render( @@ -164,7 +170,7 @@ describe('EntitySwitch', () => { }); it('should switch with sync condition that throws', async () => { - const entity = { kind: 'component' } as Entity; + const entity = { metadata: { name: 'mock' }, kind: 'component' } as Entity; const shouldRender = () => Promise.reject(); const rendered = render( diff --git a/plugins/gocd/src/components/GoCdBuildsComponent/GoCdBuildsComponent.test.tsx b/plugins/gocd/src/components/GoCdBuildsComponent/GoCdBuildsComponent.test.tsx index 7f16f40a6a..ebc3502901 100644 --- a/plugins/gocd/src/components/GoCdBuildsComponent/GoCdBuildsComponent.test.tsx +++ b/plugins/gocd/src/components/GoCdBuildsComponent/GoCdBuildsComponent.test.tsx @@ -36,7 +36,9 @@ describe('GoCdArtifactsComponent', () => { baseUrl: 'gocd.baseurl.com', }, }); - const entityValue = { entity: { metadata: {} } as Entity }; + const entityValue = { + entity: { metadata: { name: 'mock' }, kind: 'MockKind' } as Entity, + }; const renderComponent = () => renderWithEffects( diff --git a/plugins/todo/src/components/TodoList/TodoList.test.tsx b/plugins/todo/src/components/TodoList/TodoList.test.tsx index 2759fe40f8..15d4334610 100644 --- a/plugins/todo/src/components/TodoList/TodoList.test.tsx +++ b/plugins/todo/src/components/TodoList/TodoList.test.tsx @@ -38,7 +38,10 @@ describe('TodoList', () => { offset: 0, }), }; - const mockEntity = { metadata: { name: 'mock' } } as Entity; + const mockEntity = { + metadata: { name: 'mock' }, + kind: 'MockKind', + } as Entity; const rendered = await renderWithEffects(