import { IStore } from '@/typings/store' ; import { createMockStore , createStoreItem , } from '../__mocks__/mock-store-helpers' ; describe ( 'store suite' , ( ) => { const clusterName = 'clusterA' ; const findCluster = ( theStore , theName ) => theStore . discovery . clusters . cassandra . find ( ( cluster ) => cluster . name === theName ) ; it ( 'should allow replacing the store with mock data' , async ( ) => { const MockStoreModule = ( await import ( '@/model/store' ) ) as any ; const origStore = MockStoreModule . getStore ( ) ; expect ( findCluster ( MockStoreModule . getStore ( ) , clusterName ) ) . toBeUndefined ( ) ; const store = createMockStore ( [ createStoreItem ( 'cassandra' , clusterName , [ 'owner1@netflix.com' , 'owner2@netflix.com' ] , false ) , ] ) ; MockStoreModule . getStore . mockReturnValue ( store ) ; expect ( findCluster ( MockStoreModule . getStore ( ) , clusterName ) ) . toBeDefined ( ) ; MockStoreModule . getStore . mockReset ( ) ; expect ( findCluster ( origStore , clusterName ) ) . toBeUndefined ( ) ; } ) ; } ) ;