import { describe, expect, it } from 'vitest';
import { resolveUserAvatarUrl } from './utils';

describe('resolveUserAvatarUrl', () => {
	it('prioriza avatar de Workspace cuando es URL absoluta', () => {
		const value = resolveUserAvatarUrl('https://hub.example.com/media/avatar.png', '/uploads/legacy.png');
		expect(value).toBe('https://hub.example.com/media/avatar.png');
	});

	it('acepta avatar de Workspace relativo cuando no hay VITE_HUB_URL', () => {
		const value = resolveUserAvatarUrl('/media/avatar.png', '/uploads/legacy.png');
		expect(value).toBe('/media/avatar.png');
	});

	it('usa avatar legado cuando Workspace no existe', () => {
		const value = resolveUserAvatarUrl(null, '/uploads/legacy.png');
		expect(value).toBe('http://localhost:8000/uploads/legacy.png');
	});

	it('retorna vacio para fallback visual cuando no hay ninguna imagen', () => {
		const value = resolveUserAvatarUrl(null, null);
		expect(value).toBe('');
	});
});
