From e2d39d11d4714dc5a4b07d3c8f71ee60f2e0fe42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emanuel=20Tesa=C5=99?= Date: Thu, 12 Oct 2023 04:43:50 +0200 Subject: [PATCH] Fix tests --- .../pusher/src/api-requests/data-provider.test.ts | 15 +++++++++++---- packages/pusher/test/fixtures.ts | 4 +--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/packages/pusher/src/api-requests/data-provider.test.ts b/packages/pusher/src/api-requests/data-provider.test.ts index a149b09d..81683412 100644 --- a/packages/pusher/src/api-requests/data-provider.test.ts +++ b/packages/pusher/src/api-requests/data-provider.test.ts @@ -2,10 +2,11 @@ import * as adapterModule from '@api3/airnode-adapter'; import { config, - nodaryTemplateRequestErrorResponse, + nodaryTemplateRequestError, nodaryTemplateRequestResponseData, nodaryTemplateResponses, } from '../../test/fixtures'; +import { logger } from '../logger'; import * as stateModule from '../state'; import { makeTemplateRequests } from './data-provider'; @@ -24,11 +25,17 @@ describe(makeTemplateRequests.name, () => { it('handles request failure', async () => { const state = stateModule.getInitialState(config); jest.spyOn(stateModule, 'getState').mockReturnValue(state); - jest.spyOn(adapterModule, 'buildAndExecuteRequest').mockRejectedValue(nodaryTemplateRequestErrorResponse); + jest.spyOn(logger, 'warn'); + jest.spyOn(adapterModule, 'buildAndExecuteRequest').mockRejectedValue(nodaryTemplateRequestError); - await expect(makeTemplateRequests(config.triggers.signedApiUpdates[0]!)).rejects.toStrictEqual({ + await makeTemplateRequests(config.triggers.signedApiUpdates[0]!); + + expect(logger.warn).toHaveBeenCalledTimes(1); + expect(logger.warn).toHaveBeenCalledWith('Failed to make API call', { + endpointName: 'feed', errorMessage: 'Invalid API key', - success: false, + oisTitle: 'Nodary', + operationTemplateId: '0xcc35bd1800c06c12856a87311dd95bfcbb3add875844021d59a929d79f3c99bd', }); }); }); diff --git a/packages/pusher/test/fixtures.ts b/packages/pusher/test/fixtures.ts index 3701cbaa..a808efd8 100644 --- a/packages/pusher/test/fixtures.ts +++ b/packages/pusher/test/fixtures.ts @@ -109,9 +109,7 @@ export const nodaryTemplateRequestResponseData = { }, } as AxiosResponse; -export const nodaryTemplateRequestErrorResponse = { - message: 'Invalid API key', -} as AxiosError; +export const nodaryTemplateRequestError = new Error('Invalid API key'); export const nodaryTemplateResponses: TemplateResponse[] = [ [