mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
chore: finishing unit tests for a couple of services (#13292)
This commit is contained in:
parent
f5e0cdedbc
commit
9d0f03808c
17 changed files with 386 additions and 8 deletions
|
|
@ -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' });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue