import { State } from '@/typings/enums' ; import { IStore } from '@/typings/store' ; import { IClusterAClMap , IClusterDefinition , IClusterOwnership , DatastoreType , } from '@/typings/typings' ; const baseCluster = { env : 'test' , instances : [ ] , name : 'TBD' , region : 'us-east-1' , datastoreType : 'cassandra' , } ; export function createTestCluster ( datastoreType , clusterName , env = 'test' , region = 'us-east-1' ) { return { ... baseCluster , name : clusterName , datastoreType : datastoreType , env , region , } ; } export function createClusterOwnership ( clusterName , owners , isShared = false ) { return { isShared , name : clusterName , owners , } ; } export interface IMockStoreCluster { ownership : IClusterOwnership ; cluster : IClusterDefinition ; } export function createStoreItem ( datastoreType , clusterName , owners , isShared = false , env = 'test' , region = 'us-east-1' ) { return { cluster : { env , instances : [ ] , name : clusterName , region , datastoreType , } , ownership : { isShared , name : clusterName , owners , } , } ; } see createStoreItem export function createMockStore ( storeItems ) { const clusterAclMap = { } as IClusterAClMap ; const clusters = { } ; storeItems . forEach ( ( { cluster : clusterDefinition , ownership : clusterOwnership } ) => { const { name , datastoreType } = clusterDefinition ; clusterAclMap [ name ] = clusterOwnership ; clusters [ datastoreType ] = clusters [ datastoreType ] || new Array < IClusterDefinition > ( ) ; clusters [ datastoreType ] . push ( clusterDefinition ) ; } ) ; return { accessControl : { clusterAclMap , status : State . SUCCESS , } , discovery : { clusters , environments : [ 'test' ] , regions : [ 'us-east-1' ] , status : State . SUCCESS , } , } as IStore ; }