forked from Cutlery/immich
add test
This commit is contained in:
parent
f7f30a5939
commit
e26f8b45e0
@ -20,7 +20,7 @@ import {
|
|||||||
import { when } from 'jest-when';
|
import { when } from 'jest-when';
|
||||||
import { R_OK } from 'node:constants';
|
import { R_OK } from 'node:constants';
|
||||||
import { Stats } from 'node:fs';
|
import { Stats } from 'node:fs';
|
||||||
import { ILibraryFileJob, ILibraryRefreshJob, JobName } from '../job';
|
import { IEntityJob, ILibraryFileJob, ILibraryRefreshJob, JobName } from '../job';
|
||||||
import {
|
import {
|
||||||
IAssetRepository,
|
IAssetRepository,
|
||||||
ICryptoRepository,
|
ICryptoRepository,
|
||||||
@ -248,29 +248,21 @@ describe(LibraryService.name, () => {
|
|||||||
exclusionPatterns: [],
|
exclusionPatterns: [],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should set crawled assets that were previously offline back online', async () => {
|
describe('handleOfflineCheck', () => {
|
||||||
const mockLibraryJob: ILibraryRefreshJob = {
|
it('should set missing assets offline', async () => {
|
||||||
id: libraryStub.externalLibrary1.id,
|
const mockAssetJob: IEntityJob = {
|
||||||
refreshModifiedFiles: false,
|
id: assetStub.external.id,
|
||||||
refreshAllFiles: false,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
libraryMock.get.mockResolvedValue(libraryStub.externalLibrary1);
|
assetMock.getById.mockResolvedValue(assetStub.external);
|
||||||
// eslint-disable-next-line @typescript-eslint/require-await
|
|
||||||
storageMock.walk.mockImplementation(async function* generator() {
|
|
||||||
yield assetStub.offline.originalPath;
|
|
||||||
});
|
|
||||||
assetMock.getLibraryAssetPaths.mockResolvedValue({
|
|
||||||
items: [assetStub.offline],
|
|
||||||
hasNextPage: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
await sut.handleQueueAssetRefresh(mockLibraryJob);
|
storageMock.checkFileExists.mockResolvedValue(false);
|
||||||
|
|
||||||
expect(assetMock.updateAll).toHaveBeenCalledWith([assetStub.offline.id], { isOffline: false });
|
await sut.handleOfflineCheck(mockAssetJob);
|
||||||
expect(assetMock.updateAll).not.toHaveBeenCalledWith(expect.anything(), { isOffline: true });
|
|
||||||
expect(jobMock.queueAll).not.toHaveBeenCalled();
|
expect(assetMock.save).toHaveBeenCalledWith([assetStub.offline.id], { isOffline: true });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user