2025-04-30 11:17:23 -04:00
|
|
|
import { JobStatus } from 'src/enum';
|
2024-03-21 00:07:30 +01:00
|
|
|
import { AuditService } from 'src/services/audit.service';
|
2025-02-10 18:47:42 -05:00
|
|
|
import { newTestService, ServiceMocks } from 'test/utils';
|
2023-08-24 21:28:50 +02:00
|
|
|
|
|
|
|
|
describe(AuditService.name, () => {
|
|
|
|
|
let sut: AuditService;
|
2025-02-10 18:47:42 -05:00
|
|
|
let mocks: ServiceMocks;
|
2023-08-24 21:28:50 +02:00
|
|
|
|
2024-03-05 23:23:06 +01:00
|
|
|
beforeEach(() => {
|
2025-02-10 18:47:42 -05:00
|
|
|
({ sut, mocks } = newTestService(AuditService));
|
2023-08-24 21:28:50 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should work', () => {
|
|
|
|
|
expect(sut).toBeDefined();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('handleCleanup', () => {
|
|
|
|
|
it('should delete old audit entries', async () => {
|
2025-03-10 16:52:44 -04:00
|
|
|
mocks.audit.removeBefore.mockResolvedValue();
|
|
|
|
|
|
2025-07-15 14:50:13 -04:00
|
|
|
await expect(sut.handleCleanup()).resolves.toBe(JobStatus.Success);
|
2025-03-10 16:52:44 -04:00
|
|
|
|
2025-02-10 18:47:42 -05:00
|
|
|
expect(mocks.audit.removeBefore).toHaveBeenCalledWith(expect.any(Date));
|
2023-08-24 21:28:50 +02:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|