From cee1933d77eb28ad87b2a3417ffee24d60eb103a Mon Sep 17 00:00:00 2001 From: Erik Larsson Date: Wed, 27 Jan 2021 13:21:19 +0100 Subject: [PATCH] Trying to make tests work on Github too --- .../catalog/src/CatalogClientWrapper.test.ts | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/plugins/catalog/src/CatalogClientWrapper.test.ts b/plugins/catalog/src/CatalogClientWrapper.test.ts index 0306d10b5d..d95d274ee9 100644 --- a/plugins/catalog/src/CatalogClientWrapper.test.ts +++ b/plugins/catalog/src/CatalogClientWrapper.test.ts @@ -57,24 +57,17 @@ const guestIdentityApi: IdentityApi = { }; describe('CatalogClientWrapper', () => { - let client: CatalogClientWrapper; - let guestClient: CatalogClientWrapper; - beforeEach(() => { MockedCatalogClient.mockClear(); - client = new CatalogClientWrapper({ - client: new MockedCatalogClient({ discoveryApi }), - identityApi, - }); - guestClient = new CatalogClientWrapper({ - client: new MockedCatalogClient({ discoveryApi }), - identityApi: guestIdentityApi, - }); }); describe('getEntities', () => { it('injects authorization token', async () => { expect.assertions(2); + const client = new CatalogClientWrapper({ + client: new MockedCatalogClient({ discoveryApi }), + identityApi, + }); await client.getEntities(); const getEntities = MockedCatalogClient.mock.instances[0].getEntities; expect(getEntities).toHaveBeenCalledWith(undefined, { @@ -87,9 +80,13 @@ describe('CatalogClientWrapper', () => { describe('getLocationById', () => { it('omits authorization token when guest', async () => { expect.assertions(2); - await guestClient.getLocationById('42'); + const client = new CatalogClientWrapper({ + client: new MockedCatalogClient({ discoveryApi }), + identityApi: guestIdentityApi, + }); + await client.getLocationById('42'); const getLocationById = - MockedCatalogClient.mock.instances[1].getLocationById; + MockedCatalogClient.mock.instances[0].getLocationById; expect(getLocationById).toHaveBeenCalledWith('42', {}); expect(getLocationById).toHaveBeenCalledTimes(1); }); @@ -103,6 +100,10 @@ describe('CatalogClientWrapper', () => { }; it('injects authorization token', async () => { expect.assertions(2); + const client = new CatalogClientWrapper({ + client: new MockedCatalogClient({ discoveryApi }), + identityApi, + }); await client.getEntityByName(name); const getEntityByName = MockedCatalogClient.mock.instances[0].getEntityByName; @@ -117,6 +118,10 @@ describe('CatalogClientWrapper', () => { const location = { target: 'target' }; it('injects authorization token', async () => { expect.assertions(2); + const client = new CatalogClientWrapper({ + client: new MockedCatalogClient({ discoveryApi }), + identityApi, + }); await client.addLocation(location); const addLocation = MockedCatalogClient.mock.instances[0].addLocation; expect(addLocation).toHaveBeenCalledWith(location, { @@ -136,6 +141,10 @@ describe('CatalogClientWrapper', () => { }; it('injects authorization token', async () => { expect.assertions(2); + const client = new CatalogClientWrapper({ + client: new MockedCatalogClient({ discoveryApi }), + identityApi, + }); await client.getLocationByEntity(entity); const getLocationByEntity = MockedCatalogClient.mock.instances[0].getLocationByEntity; @@ -150,6 +159,10 @@ describe('CatalogClientWrapper', () => { it('injects authorization token', async () => { const uid = 'uid'; expect.assertions(2); + const client = new CatalogClientWrapper({ + client: new MockedCatalogClient({ discoveryApi }), + identityApi, + }); await client.removeEntityByUid(uid); const removeEntityByUid = MockedCatalogClient.mock.instances[0].removeEntityByUid;