import { VoiceService } from '../../src/services/VoiceService';
import { VoiceState } from 'discord.js';

describe('VoiceService Test Suite', () => {
  it('should ignore when member is not present in the voice state', async () => {
    // Mocking discord.js objects is complex, so we ensure the service handles null safety
    const mockState = { channelId: null } as VoiceState;
    await VoiceService.handleVoiceStateUpdate(mockState, mockState);
    expect(true).toBe(true);
  });

  it('should resolve nickname correctly in getEffectiveName', () => {
    const mockMember = {
      id: '123',
      nickname: 'ServerNick',
      user: {
        globalName: 'GlobalName',
        username: 'UserBase',
        id: '123'
      }
    } as any;

    expect(VoiceService.getEffectiveName(mockMember)).toBe('ServerNick');

    mockMember.nickname = null;
    expect(VoiceService.getEffectiveName(mockMember)).toBe('GlobalName');

    mockMember.user.globalName = null;
    expect(VoiceService.getEffectiveName(mockMember)).toBe('UserBase');

    mockMember.user.username = null;
    expect(VoiceService.getEffectiveName(mockMember)).toBe('123');
  });
});
