fix: Prevent microphone auto-disconnect during calls and restore the removed microphone connected condition (#2597)
- Closes: #2590
This commit is contained in:
@@ -34,6 +34,72 @@ describe('MicrophoneTrigger', () => {
|
||||
expect(callback).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should trigger on any connection change without a value', () => {
|
||||
const { stateManager, callback } = create({ trigger: 'microphone' });
|
||||
stateManager.setState({ microphone: createMicrophoneState({ connected: true }) });
|
||||
stateManager.setState({ microphone: createMicrophoneState({ connected: false }) });
|
||||
expect(callback).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('should trigger only on changes to the given connected value', () => {
|
||||
const { stateManager, callback } = create({
|
||||
trigger: 'microphone',
|
||||
connected: true,
|
||||
});
|
||||
stateManager.setState({ microphone: createMicrophoneState({ connected: true }) });
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
|
||||
stateManager.setState({ microphone: createMicrophoneState({ connected: false }) });
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should not trigger on a mute change when only connected is given', () => {
|
||||
const { stateManager, callback } = create({
|
||||
trigger: 'microphone',
|
||||
connected: true,
|
||||
});
|
||||
stateManager.setState({
|
||||
microphone: createMicrophoneState({ connected: true, muted: true }),
|
||||
});
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
|
||||
stateManager.setState({
|
||||
microphone: createMicrophoneState({ connected: true, muted: false }),
|
||||
});
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should not trigger on a connection change when only muted is given', () => {
|
||||
const { stateManager, callback } = create({ trigger: 'microphone', muted: true });
|
||||
stateManager.setState({
|
||||
microphone: createMicrophoneState({ connected: false, muted: true }),
|
||||
});
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
|
||||
stateManager.setState({
|
||||
microphone: createMicrophoneState({ connected: true, muted: true }),
|
||||
});
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should require both connected and muted to match when both are given', () => {
|
||||
const { stateManager, callback } = create({
|
||||
trigger: 'microphone',
|
||||
connected: true,
|
||||
muted: false,
|
||||
});
|
||||
|
||||
stateManager.setState({
|
||||
microphone: createMicrophoneState({ connected: true, muted: true }),
|
||||
});
|
||||
expect(callback).not.toHaveBeenCalled();
|
||||
|
||||
stateManager.setState({
|
||||
microphone: createMicrophoneState({ connected: true, muted: false }),
|
||||
});
|
||||
expect(callback).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should trigger only on changes to the given mute value', () => {
|
||||
const { stateManager, callback } = create({ trigger: 'microphone', muted: true });
|
||||
stateManager.setState({ microphone: createMicrophoneState({ muted: true }) });
|
||||
|
||||
Reference in New Issue
Block a user