mirror of
https://github.com/immich-app/immich.git
synced 2026-04-18 06:51:59 -04:00
* feat: admin repair orphans tool * chore: open api * fix: include upload folder * fix: bugs * feat: empty placeholder * fix: checks * feat: move buttons to top of page * feat: styling and clipboard * styling * better clicking hitbox * fix: show title on hover * feat: download report * restrict file access to immich related files * Add description --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com> Co-authored-by: Daniel Dietzler <mail@ddietzler.dev>
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
import { newStorageRepositoryMock } from '@test';
|
|
import { IStorageRepository } from '../repositories';
|
|
import { StorageService } from './storage.service';
|
|
|
|
describe(StorageService.name, () => {
|
|
let sut: StorageService;
|
|
let storageMock: jest.Mocked<IStorageRepository>;
|
|
|
|
beforeEach(async () => {
|
|
storageMock = newStorageRepositoryMock();
|
|
sut = new StorageService(storageMock);
|
|
});
|
|
|
|
it('should work', () => {
|
|
expect(sut).toBeDefined();
|
|
});
|
|
|
|
describe('init', () => {
|
|
it('should create the library folder on initialization', () => {
|
|
sut.init();
|
|
expect(storageMock.mkdirSync).toHaveBeenCalledWith('upload/library');
|
|
});
|
|
});
|
|
|
|
describe('handleDeleteFiles', () => {
|
|
it('should handle null values', async () => {
|
|
await sut.handleDeleteFiles({ files: [undefined, null] });
|
|
|
|
expect(storageMock.unlink).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it('should handle an error removing a file', async () => {
|
|
storageMock.unlink.mockRejectedValue(new Error('something-went-wrong'));
|
|
|
|
await sut.handleDeleteFiles({ files: ['path/to/something'] });
|
|
|
|
expect(storageMock.unlink).toHaveBeenCalledWith('path/to/something');
|
|
});
|
|
|
|
it('should remove the file', async () => {
|
|
await sut.handleDeleteFiles({ files: ['path/to/something'] });
|
|
|
|
expect(storageMock.unlink).toHaveBeenCalledWith('path/to/something');
|
|
});
|
|
});
|
|
});
|