immich/server/src/cores/storage.core.spec.ts
2025-02-11 14:08:13 -05:00

33 lines
1.1 KiB
TypeScript

import { StorageCore } from 'src/cores/storage.core';
import { vitest } from 'vitest';
vitest.mock('src/constants', () => ({
APP_MEDIA_LOCATION: '/photos',
ADDED_IN_PREFIX: 'This property was added in ',
DEPRECATED_IN_PREFIX: 'This property was deprecated in ',
IWorker: 'IWorker',
}));
describe('StorageCore', () => {
describe('isImmichPath', () => {
it('should return true for APP_MEDIA_LOCATION path', () => {
const immichPath = '/photos';
expect(StorageCore.isImmichPath(immichPath)).toBe(true);
});
it('should return true for paths within the APP_MEDIA_LOCATION', () => {
const immichPath = '/photos/new/';
expect(StorageCore.isImmichPath(immichPath)).toBe(true);
});
it('should return false for paths outside the APP_MEDIA_LOCATION and same starts', () => {
const nonImmichPath = '/photos_new';
expect(StorageCore.isImmichPath(nonImmichPath)).toBe(false);
});
it('should return false for paths outside the APP_MEDIA_LOCATION', () => {
const nonImmichPath = '/some/other/path';
expect(StorageCore.isImmichPath(nonImmichPath)).toBe(false);
});
});
});