import sinon , { SinonFakeServer } from 'sinon' ; import { Cluster } from '../../../common/lib' ; const registerHttpRequestMockHelpers = ( server ) => { const mockResponse = ( response ) => [ 200 , { 'Content-Type' : 'application/json' } , JSON . stringify ( response ) , ] ; const setLoadRemoteClustersResponse = ( response = [ ] ) => { server . respondWith ( 'GET' , '/api/remote_clusters' , mockResponse ( response ) ) ; } ; const setDeleteRemoteClusterResponse = ( response = { itemsDeleted : [ ] , errors : [ ] } ) => { server . respondWith ( 'DELETE' , /api\/remote_clusters/ , mockResponse ( response ) ) ; } ; return { setLoadRemoteClustersResponse , setDeleteRemoteClusterResponse , } ; } ; export const init = ( ) => { const server = sinon . fakeServer . create ( ) ; server . respondImmediately = true ; server . respondWith ( [ 200 , { } , '' ] ) ; return { server , httpRequestsMockHelpers : registerHttpRequestMockHelpers ( server ) , } ; } ;