Files
Toju/toju-app/src/app/domains/voice-session/domain/logic/client-voice-session.rules.spec.ts
Myx eb51f043ac
All checks were successful
Queue Release Build / prepare (push) Successful in 19s
Deploy Web Apps / deploy (push) Successful in 8m12s
Queue Release Build / build-windows (push) Successful in 27m44s
Queue Release Build / build-linux (push) Successful in 48m1s
Queue Release Build / build-android (push) Successful in 22m7s
Queue Release Build / finalize (push) Successful in 2m42s
fix: Major bug cleanup pass 1
2026-06-09 17:59:54 +02:00

55 lines
1.6 KiB
TypeScript

import {
describe,
expect,
it
} from 'vitest';
import type { VoiceState } from '../../../../shared-kernel';
import {
isLocalVoiceOwner,
isVoiceOnAnotherClient,
shouldTransmitVoice
} from './client-voice-session.rules';
describe('client-voice-session.rules', () => {
const localClientInstanceId = 'device-a';
it('treats the matching client instance as the local voice owner', () => {
const voiceState: VoiceState = {
isConnected: true,
isMuted: false,
isDeafened: false,
isSpeaking: false,
clientInstanceId: localClientInstanceId
};
expect(isLocalVoiceOwner(voiceState, localClientInstanceId)).toBe(true);
expect(isVoiceOnAnotherClient(voiceState, localClientInstanceId)).toBe(false);
expect(shouldTransmitVoice(voiceState, localClientInstanceId)).toBe(true);
});
it('treats a different client instance as passive voice', () => {
const voiceState: VoiceState = {
isConnected: true,
isMuted: false,
isDeafened: false,
isSpeaking: false,
clientInstanceId: 'device-b'
};
expect(isLocalVoiceOwner(voiceState, localClientInstanceId)).toBe(false);
expect(isVoiceOnAnotherClient(voiceState, localClientInstanceId)).toBe(true);
expect(shouldTransmitVoice(voiceState, localClientInstanceId)).toBe(false);
});
it('allows transmission when disconnected', () => {
const voiceState: VoiceState = {
isConnected: false,
isMuted: false,
isDeafened: false,
isSpeaking: false
};
expect(shouldTransmitVoice(voiceState, localClientInstanceId)).toBe(true);
});
});