import { DEFAULT_SPACE_ID } from '../../common/constants' ; import { namespaceToSpaceId , spaceIdToNamespace } from '../lib/utils/namespace' ; import { spacesClientMock } from '../spaces_client/spaces_client.mock' ; import type { SpacesServiceSetup , SpacesServiceStart } from './spaces_service' ; const createSetupContractMock = ( spaceId = DEFAULT_SPACE_ID ) => { const setupContract = { namespaceToSpaceId : jest . fn ( ) . mockImplementation ( namespaceToSpaceId ) , spaceIdToNamespace : jest . fn ( ) . mockImplementation ( spaceIdToNamespace ) , getSpaceId : jest . fn ( ) . mockReturnValue ( spaceId ) , } ; return setupContract ; } ; const createStartContractMock = ( spaceId = DEFAULT_SPACE_ID ) => { const startContract = { namespaceToSpaceId : jest . fn ( ) . mockImplementation ( namespaceToSpaceId ) , spaceIdToNamespace : jest . fn ( ) . mockImplementation ( spaceIdToNamespace ) , createSpacesClient : jest . fn ( ) . mockReturnValue ( spacesClientMock . create ( ) ) , getSpaceId : jest . fn ( ) . mockReturnValue ( spaceId ) , isInDefaultSpace : jest . fn ( ) . mockReturnValue ( spaceId === DEFAULT_SPACE_ID ) , getActiveSpace : jest . fn ( ) , } ; return startContract ; } ; export const spacesServiceMock = { createSetupContract : createSetupContractMock , createStartContract : createStartContractMock , } ;