mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 01:11:46 +03:00
refactor: controller tests (#18035)
* feat: controller unit tests * refactor: controller tests
This commit is contained in:
28
server/src/controllers/server.controller.spec.ts
Normal file
28
server/src/controllers/server.controller.spec.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { ServerController } from 'src/controllers/server.controller';
|
||||
import { ServerService } from 'src/services/server.service';
|
||||
import { VersionService } from 'src/services/version.service';
|
||||
import request from 'supertest';
|
||||
import { ControllerContext, controllerSetup, mockBaseService } from 'test/utils';
|
||||
|
||||
describe(ServerController.name, () => {
|
||||
let ctx: ControllerContext;
|
||||
|
||||
beforeAll(async () => {
|
||||
ctx = await controllerSetup(ServerController, [
|
||||
{ provide: ServerService, useValue: mockBaseService(ServerService) },
|
||||
{ provide: VersionService, useValue: mockBaseService(VersionService) },
|
||||
]);
|
||||
return () => ctx.close();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.reset();
|
||||
});
|
||||
|
||||
describe('GET /server/license', () => {
|
||||
it('should be an authenticated route', async () => {
|
||||
await request(ctx.getHttpServer()).get('/server/license');
|
||||
expect(ctx.authenticate).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user