mirror of
https://github.com/immich-app/immich.git
synced 2026-03-22 20:39:58 +03:00
fix: null validation (#25891)
This commit is contained in:
34
server/src/controllers/shared-link.controller.spec.ts
Normal file
34
server/src/controllers/shared-link.controller.spec.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { SharedLinkController } from 'src/controllers/shared-link.controller';
|
||||
import { SharedLinkType } from 'src/enum';
|
||||
import { SharedLinkService } from 'src/services/shared-link.service';
|
||||
import request from 'supertest';
|
||||
import { ControllerContext, controllerSetup, mockBaseService } from 'test/utils';
|
||||
|
||||
describe(SharedLinkController.name, () => {
|
||||
let ctx: ControllerContext;
|
||||
const service = mockBaseService(SharedLinkService);
|
||||
|
||||
beforeAll(async () => {
|
||||
ctx = await controllerSetup(SharedLinkController, [{ provide: SharedLinkService, useValue: service }]);
|
||||
return () => ctx.close();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
service.resetAllMocks();
|
||||
ctx.reset();
|
||||
});
|
||||
|
||||
describe('POST /shared-links', () => {
|
||||
it('should be an authenticated route', async () => {
|
||||
await request(ctx.getHttpServer()).post('/shared-links');
|
||||
expect(ctx.authenticate).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should allow an null expiresAt', async () => {
|
||||
await request(ctx.getHttpServer())
|
||||
.post('/shared-links')
|
||||
.send({ expiresAt: null, type: SharedLinkType.Individual });
|
||||
expect(service.create).toHaveBeenCalledWith(undefined, expect.objectContaining({ expiresAt: null }));
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user