import type { Persistor } from 'redux-persist' ; import { SegmentClient } from '../../analytics' ; import { Logger } from '../../logger' ; import type { MainState } from '../../store/main' ; import { ReduxStorage } from '../../storage' ; import type { SystemState } from '../../store/system' ; import type { UserInfoState } from '../../store/userInfo' ; import type { Config } from '../../types' ; import { mockPersistor } from './mockPersistor' ; jest . mock ( '../../context' ) ; jest . mock ( 'react-native' ) ; const getMockLogger = ( ) => { const logger = new Logger ( ) ; logger . disable ( ) ; logger . info = jest . fn ( ) ; logger . warn = jest . fn ( ) ; logger . error = jest . fn ( ) ; return logger ; } ; mockPersistor . getState = jest . fn ( ) . mockReturnValue ( { bootstrapped : true , } ) ; param state returns export const getMockReduxStorage = ( state ? ) => { return new ReduxStorage ( { subscribe : jest . fn ( ) , dispatch : jest . fn ( ) , getState : ( ) => ( { userInfo : { anonymousId : 'my-id' , userId : 'user-id' , } , main : { events : [ ] , context : { app : { build : '1' , version : '1.2' , } , } , } , system : { settings : { integrations : { } , } , } , ... state , } ) , } , mockPersistor ) ; } ; param configOverride returns export const getTestClient = ( configOverride ? ) => { const clientArgs = { config : { writeKey : 'SEGMENT_KEY' , flushAt : 10 , retryInterval : 40 , } , logger : getMockLogger ( ) , persistor : mockPersistor , store : getMockReduxStorage ( ) , ... configOverride , } ; return new SegmentClient ( clientArgs ) ; } ;