mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-06 02:34:21 +00:00
9bb5854dbb
src/services is gone, so the folder named a layer that no longer exists. The airtrail suites go to tests/unit/nest/integrations, the crypto, cookie, avatar, password policy, timezone and conflict helpers to tests/unit/nest/common, the kitinerary mapper to booking-import, the photo media suite to photos, the atlas bundle guard to tests/unit/nest and the two migration suites to tests/unit/db. Only the relative import paths change, and the format baseline follows the new paths.
26 lines
1017 B
TypeScript
26 lines
1017 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 { describe, it, expect } from 'vitest';
|
|
import { avatarUrl } from '../../../../src/nest/common/avatarUrl';
|
|
|
|
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();
|
|
});
|
|
});
|