import '../../compass-requests/helpers/mockRequestAtlassian'; import { ApiPayload, CompassCreateEventInput, CompassInsertMetricValueByExternalIdInput, ComponentReferenceInput, CreateCompassComponentExternalAliasInput, CreateComponentInput, DeleteCompassComponentExternalAliasInput, GetAllComponentTypesInput, GetComponentByExternalAliasInput, GetComponentInput, UpdateCompassComponentDataManagerMetadataInput, UpdateComponentInput, } from '@atlassian/forge-graphql-types'; import api from '../../../index'; const defaultImpl = async (optionalInput?: any): Promise> => ({ success: true, errors: [], data: {}, }); export const mockDeleteExternalAlias = jest.fn(defaultImpl); export const mockDetachDataManager = jest.fn(defaultImpl); export const mockGetComponent = jest.fn(defaultImpl); export const mockCreateExternalAlias = jest.fn(defaultImpl); export const mockUpdateComponent = jest.fn(defaultImpl); export const mockUpdateComponentDataManager = jest.fn(defaultImpl); export const mockCreateEvent = jest.fn(defaultImpl); export const mockInsertMetricValueByExternalId = jest.fn(defaultImpl); export const mockCreateComponent = jest.fn(defaultImpl); export const mockGetComponentByExternalAlias = jest.fn(defaultImpl); export const mockGetComponentsByReferences = jest.fn(defaultImpl); export const mockGetAllComponentTypes = jest.fn(defaultImpl); export function mockAggCompassRequests() { const compassReq = api.compass.asApp(); jest .spyOn(compassReq, 'getComponent') .mockImplementation((input: GetComponentInput) => mockGetComponent(input)); jest .spyOn(compassReq, 'deleteExternalAlias') .mockImplementation((input: DeleteCompassComponentExternalAliasInput) => mockDeleteExternalAlias(input), ); jest .spyOn(compassReq, 'detachDataManager') .mockImplementation((input: GetComponentInput) => mockDetachDataManager(input), ); jest .spyOn(compassReq, 'createExternalAlias') .mockImplementation((input: CreateCompassComponentExternalAliasInput) => mockCreateExternalAlias(input), ); jest .spyOn(compassReq, 'updateComponent') .mockImplementation((input: UpdateComponentInput) => mockUpdateComponent(input), ); jest .spyOn(compassReq, 'updateDataManager') .mockImplementation( (input: UpdateCompassComponentDataManagerMetadataInput) => mockUpdateComponentDataManager(input), ); jest .spyOn(compassReq, 'createEvent') .mockImplementation( (input: CompassCreateEventInput | CompassCreateEventInput[]) => mockCreateEvent(input), ); jest .spyOn(compassReq, 'insertMetricValueByExternalId') .mockImplementation((input: CompassInsertMetricValueByExternalIdInput) => mockInsertMetricValueByExternalId(input), ); jest .spyOn(compassReq, 'createComponent') .mockImplementation((input: CreateComponentInput) => mockCreateComponent(input), ); jest .spyOn(compassReq, 'getComponentByExternalAlias') .mockImplementation((input: GetComponentByExternalAliasInput) => mockGetComponentByExternalAlias(input), ); jest .spyOn(compassReq, 'getComponentsByReferences') .mockImplementation((input: ComponentReferenceInput[]) => mockGetComponentsByReferences(input), ); jest .spyOn(compassReq, 'getAllComponentTypes') .mockImplementation((input: GetAllComponentTypesInput) => mockGetAllComponentTypes(input), ); }