mirror of
https://github.com/immich-app/immich
synced 2026-08-29 13:15:45 +00:00
38 lines
1.4 KiB
TypeScript
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' }]));
|
|
});
|
|
});
|
|
});
|