mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
refactor: timeline tests (#19641)
This commit is contained in:
parent
58ca1402ed
commit
93f9e118ad
3 changed files with 200 additions and 230 deletions
41
server/src/controllers/timeline.controller.spec.ts
Normal file
41
server/src/controllers/timeline.controller.spec.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
import { TimelineController } from 'src/controllers/timeline.controller';
|
||||
import { TimelineService } from 'src/services/timeline.service';
|
||||
import request from 'supertest';
|
||||
import { errorDto } from 'test/medium/responses';
|
||||
import { ControllerContext, controllerSetup, mockBaseService } from 'test/utils';
|
||||
|
||||
describe(TimelineController.name, () => {
|
||||
let ctx: ControllerContext;
|
||||
const service = mockBaseService(TimelineService);
|
||||
|
||||
beforeAll(async () => {
|
||||
ctx = await controllerSetup(TimelineController, [{ provide: TimelineService, useValue: service }]);
|
||||
return () => ctx.close();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service.resetAllMocks();
|
||||
ctx.reset();
|
||||
});
|
||||
|
||||
describe('GET /timeline/buckets', () => {
|
||||
it('should be an authenticated route', async () => {
|
||||
await request(ctx.getHttpServer()).get('/timeline/buckets');
|
||||
expect(ctx.authenticate).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe('GET /timeline/bucket', () => {
|
||||
it('should be an authenticated route', async () => {
|
||||
await request(ctx.getHttpServer()).get('/timeline/bucket?timeBucket=1900-01-01');
|
||||
expect(ctx.authenticate).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
// TODO enable date string validation while still accepting 5 digit years
|
||||
it.fails('should fail if time bucket is invalid', async () => {
|
||||
const { status, body } = await request(ctx.getHttpServer()).get('/timeline/bucket').query({ timeBucket: 'foo' });
|
||||
expect(status).toBe(400);
|
||||
expect(body).toEqual(errorDto.badRequest('Invalid time bucket format'));
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue