35 أسطر
1.3 KiB
TypeScript
35 أسطر
1.3 KiB
TypeScript
import { UsersController } from './users.controller';
|
|
|
|
describe('UsersController artist dashboard', () => {
|
|
it('uses the authenticated user id for the private dashboard endpoint', async () => {
|
|
const usersService = {
|
|
getMyDashboard: jest.fn().mockResolvedValue({ profile: { _id: 'user-1' } }),
|
|
};
|
|
const controller = new UsersController(usersService as any);
|
|
|
|
const result = await controller.getMyDashboard({ sub: 'user-1' } as any);
|
|
|
|
expect(usersService.getMyDashboard).toHaveBeenCalledWith('user-1');
|
|
expect(result).toEqual({ profile: { _id: 'user-1' } });
|
|
});
|
|
});
|
|
|
|
describe('UsersController profile lookup', () => {
|
|
it('uses the authenticated user id when loading profile overview by username', async () => {
|
|
const usersService = {
|
|
getProfileOverviewByUsername: jest.fn().mockResolvedValue({
|
|
profileShareUrl: 'https://oudelaa.com/u/artist',
|
|
}),
|
|
};
|
|
const controller = new UsersController(usersService as any);
|
|
|
|
const result = await controller.getProfileOverviewByUsername(
|
|
{ sub: 'viewer-1' } as any,
|
|
'artist',
|
|
);
|
|
|
|
expect(usersService.getProfileOverviewByUsername).toHaveBeenCalledWith('artist', 'viewer-1');
|
|
expect(result).toEqual({ profileShareUrl: 'https://oudelaa.com/u/artist' });
|
|
});
|
|
});
|