2024-03-31 16:47:03 +02:00
|
|
|
import { StorageCore } from 'src/cores/storage.core';
|
2024-04-16 16:44:45 +02:00
|
|
|
import { vitest } from 'vitest';
|
2024-03-31 16:47:03 +02:00
|
|
|
|
2024-04-16 16:44:45 +02:00
|
|
|
vitest.mock('src/constants', () => ({
|
2024-03-31 16:47:03 +02:00
|
|
|
APP_MEDIA_LOCATION: '/photos',
|
|
|
|
}));
|
|
|
|
|
|
|
|
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);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|