From c5cf37026ec31e83364e3c655e2594588892733e Mon Sep 17 00:00:00 2001 From: Taras Date: Thu, 8 Sep 2022 11:55:08 -0400 Subject: [PATCH] Add test for unexpected error Signed-off-by: Taras --- .../catalog-client/src/CatalogClient.test.ts | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/catalog-client/src/CatalogClient.test.ts b/packages/catalog-client/src/CatalogClient.test.ts index 263bb8971d..6c9c68efa2 100644 --- a/packages/catalog-client/src/CatalogClient.test.ts +++ b/packages/catalog-client/src/CatalogClient.test.ts @@ -356,5 +356,26 @@ describe('CatalogClient', () => { valid: true, }); }); + + it('throws unexpected error', async () => { + server.use( + rest.post(`${mockBaseUrl}/validate-entity`, (_req, res, ctx) => { + return res(ctx.status(500), ctx.json({})); + }), + ); + + await expect(() => + client.validateEntity( + { + apiVersion: '1', + kind: 'Component', + metadata: { + name: 'good', + }, + }, + 'http://example.com', + ), + ).rejects.toThrow(/Request failed with 500 Error/); + }); }); });