From cba80192435aaa223344cc35bcf1f28e66bf6733 Mon Sep 17 00:00:00 2001 From: Jonathan Jogenfors Date: Wed, 20 Mar 2024 11:58:36 +0100 Subject: [PATCH] add test for already-online assets --- .../src/domain/library/library.service.spec.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/server/src/domain/library/library.service.spec.ts b/server/src/domain/library/library.service.spec.ts index c907f6f48..3266479f1 100644 --- a/server/src/domain/library/library.service.spec.ts +++ b/server/src/domain/library/library.service.spec.ts @@ -306,7 +306,7 @@ describe(LibraryService.name, () => { expect(assetMock.update).toHaveBeenCalledWith({ id: assetStub.external.id, isOffline: true }); }); - it('should skip an offline asset', async () => { + it('should skip an already-offline asset', async () => { const mockAssetJob: ILibraryOfflineJob = { id: assetStub.external.id, importPaths: ['/'], @@ -322,6 +322,22 @@ describe(LibraryService.name, () => { expect(assetMock.update).not.toHaveBeenCalled(); }); + it('should do nothing if asset is still online', async () => { + const mockAssetJob: ILibraryOfflineJob = { + id: assetStub.external.id, + importPaths: ['/'], + }; + + assetMock.getById.mockResolvedValue(assetStub.external); + + storageMock.checkFileExists.mockResolvedValue(true); + + const response = await sut.handleOfflineCheck(mockAssetJob); + expect(response).toBe(JobStatus.SUCCESS); + + expect(assetMock.update).not.toHaveBeenCalled(); + }); + it('should skip a nonexistent asset id', async () => { const mockAssetJob: ILibraryOfflineJob = { id: assetStub.external.id,