immich/server/src/controllers/album.controller.spec.ts
Jason Rasmussen 1b8cbaab97
refactor(server): migrate e2e auth/validation tests to controller specs (#30715)
Co-authored-by: Claude (thor) <claude@thor.local>
2026-08-11 11:02:14 -04:00

38 lines
1.4 KiB
TypeScript

import { AlbumController } from 'src/controllers/album.controller';
import { AlbumService } from 'src/services/album.service';
import request from 'supertest';
import { factory } from 'test/small.factory';
import { ControllerContext, controllerSetup, mockBaseService } from 'test/utils';
describe(AlbumController.name, () => {
let ctx: ControllerContext;
const service = mockBaseService(AlbumService);
beforeAll(async () => {
ctx = await controllerSetup(AlbumController, [{ provide: AlbumService, useValue: service }]);
return () => ctx.close();
});
beforeEach(() => {
service.resetAllMocks();
ctx.reset();
});
describe('GET /albums', () => {
it('should reject an invalid shared param', async () => {
const { status, body } = await request(ctx.getHttpServer()).get('/albums?isShared=invalid');
expect(status).toEqual(400);
expect(body).toEqual(
factory.responses.validationError([
{ path: ['isShared'], message: 'Invalid option: expected one of "true"|"false"' },
]),
);
});
it('should reject an invalid assetId param', async () => {
const { status, body } = await request(ctx.getHttpServer()).get('/albums?assetId=invalid');
expect(status).toEqual(400);
expect(body).toEqual(factory.responses.validationError([{ path: ['assetId'], message: 'Invalid UUID' }]));
});
});
});