import { VendedoresCobradoresService } from './vendedores-cobradores.service';

/** U17: el POS trae elegido el vendedor vinculado al usuario. */
describe('VendedoresCobradoresService.findVendedorVinculado', () => {
  it('busca un vendedor activo (vendedor o ambos) del usuario en la empresa', async () => {
    const service = Object.create(VendedoresCobradoresService.prototype) as any;
    service.prisma = { vendedores_cobradores: { findFirst: jest.fn().mockResolvedValue({ id: 'v1' }) } };
    expect(await service.findVendedorVinculado('emp', 'usr')).toEqual({ id: 'v1' });
    expect(service.prisma.vendedores_cobradores.findFirst).toHaveBeenCalledWith(
      expect.objectContaining({
        where: { empresa_id: 'emp', usuario_id: 'usr', active: true, tipo: { in: ['vendedor', 'ambos'] } },
      }),
    );
  });
});
