mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 05:26:47 +00:00
724c88c201
A mechanical prettier --write over server/src, server/tests, server/scripts and shared/src with the workspaces' .prettierrc; nothing but layout and import order changes, and every file keeps the same set of imports. shared is formatted throughout and its format baseline is empty. The server baseline keeps the 35 files that Prettier would grow past their lint:size limit (they need a split first, which is not a formatting change), and the generated entity files stay as their generator writes them.
25 lines
1005 B
TypeScript
25 lines
1005 B
TypeScript
/**
|
|
* Unit tests for avatarUrl — AVATAR-URL-001 through AVATAR-URL-003.
|
|
* The stored value is either an uploaded file name or an absolute https URL from
|
|
* an OIDC `picture` claim (#1399); the helper resolves both to a renderable src.
|
|
*/
|
|
import { avatarUrl } from '../../../../src/nest/common/avatarUrl';
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
describe('avatarUrl', () => {
|
|
it('AVATAR-URL-001: prefixes an uploaded file name with the avatars path', () => {
|
|
expect(avatarUrl({ avatar: 'abc123.jpg' })).toBe('/uploads/avatars/abc123.jpg');
|
|
});
|
|
|
|
it('AVATAR-URL-002: passes an absolute https URL (OIDC picture) through untouched', () => {
|
|
expect(avatarUrl({ avatar: 'https://idp.example.com/u/pic.png' })).toBe('https://idp.example.com/u/pic.png');
|
|
});
|
|
|
|
it('AVATAR-URL-003: returns null when no avatar is set', () => {
|
|
expect(avatarUrl({ avatar: null })).toBeNull();
|
|
expect(avatarUrl({ avatar: undefined })).toBeNull();
|
|
expect(avatarUrl({})).toBeNull();
|
|
});
|
|
});
|