import { DeviceManagerState , LocalVideoStreamState } from '@internal/calling-stateful-client' ; import { _isInCall , _isPreviewOn } from './callUtils' ; const deviceManagerMock = { isSpeakerSelectionAvailable : false , cameras : [ ] , microphones : [ ] , speakers : [ ] , unparentedViews : [ ] } ; const invalidLocalVideoStreamMock = { source : { name : 'test-stream' , id : 'test-id' , deviceType : 'Unknown' } , mediaStreamType : 'Video' , view : undefined } ; const validLocalVideoStreamMock = { ... invalidLocalVideoStreamMock , view : { scalingMode : 'Stretch' , isMirrored : false , target : null as any } } ; describe ( 'callUtils tests' , ( ) => { test ( 'isInCall should return true if state is anything other than none or disconnected' , ( ) => { expect ( _isInCall ( 'None' ) ) . toEqual ( false ) ; expect ( _isInCall ( 'Disconnected' ) ) . toEqual ( false ) ; expect ( _isInCall ( 'Connecting' ) ) . toEqual ( false ) ; expect ( _isInCall ( 'Ringing' ) ) . toEqual ( true ) ; expect ( _isInCall ( 'Connected' ) ) . toEqual ( true ) ; expect ( _isInCall ( 'LocalHold' ) ) . toEqual ( true ) ; expect ( _isInCall ( 'RemoteHold' ) ) . toEqual ( true ) ; expect ( _isInCall ( 'InLobby' ) ) . toEqual ( true ) ; expect ( _isInCall ( 'Disconnecting' ) ) . toEqual ( true ) ; expect ( _isInCall ( 'EarlyMedia' ) ) . toEqual ( true ) ; } ) ; test ( '_isPreviewOn should return true if detached views exist in the device manager' , ( ) => { expect ( _isPreviewOn ( { ... deviceManagerMock , unparentedViews : [ ] } ) ) . toEqual ( false ) ; expect ( _isPreviewOn ( { ... deviceManagerMock , unparentedViews : [ invalidLocalVideoStreamMock ] } ) ) . toEqual ( false ) ; expect ( _isPreviewOn ( { ... deviceManagerMock , unparentedViews : [ validLocalVideoStreamMock ] } ) ) . toEqual ( true ) ; } ) ; } ) ;