chore: finishing unit tests for a couple of services (#13292)

This commit is contained in:
Daniel Dietzler 2024-10-08 23:08:49 +02:00 committed by GitHub
parent f5e0cdedbc
commit 9d0f03808c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 386 additions and 8 deletions

View file

@ -126,6 +126,14 @@ describe(NotificationService.name, () => {
await expect(sut.onConfigValidate({ oldConfig, newConfig })).resolves.not.toThrow();
expect(notificationMock.verifySmtp).not.toHaveBeenCalled();
});
it('should fail if smtp configuration is invalid', async () => {
const oldConfig = configs.smtpDisabled;
const newConfig = configs.smtpEnabled;
notificationMock.verifySmtp.mockRejectedValue(new Error('Failed validating smtp'));
await expect(sut.onConfigValidate({ oldConfig, newConfig })).rejects.toBeInstanceOf(Error);
});
});
describe('onAssetHide', () => {
@ -180,6 +188,18 @@ describe(NotificationService.name, () => {
});
});
describe('onSessionDeleteEvent', () => {
it('should send a on_session_delete client event', () => {
vi.useFakeTimers();
sut.onSessionDelete({ sessionId: 'id' });
expect(eventMock.clientSend).not.toHaveBeenCalled();
vi.advanceTimersByTime(500);
expect(eventMock.clientSend).toHaveBeenCalledWith('on_session_delete', 'id', 'id');
});
});
describe('onAssetTrash', () => {
it('should send connected clients an event', () => {
sut.onAssetTrash({ assetId: 'asset-id', userId: 'user-id' });