2024-03-02 16:25:27 +02:00
|
|
|
import { getDisplayParentId, getTrashFolderId } from '.';
|
2024-03-14 20:30:49 +02:00
|
|
|
import { ModelType } from '../../BaseModel';
|
2024-03-29 14:11:15 +02:00
|
|
|
import Folder from '../../models/Folder';
|
2024-03-02 16:25:27 +02:00
|
|
|
|
|
|
|
describe('services/trash', () => {
|
|
|
|
|
|
|
|
test.each([
|
|
|
|
[
|
|
|
|
{
|
|
|
|
deleted_time: 0,
|
|
|
|
parent_id: '1',
|
2024-03-14 20:30:49 +02:00
|
|
|
id: 'a',
|
2024-03-02 16:25:27 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
deleted_time: 0,
|
2024-03-14 20:30:49 +02:00
|
|
|
id: '1',
|
2024-03-02 16:25:27 +02:00
|
|
|
},
|
|
|
|
'1',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
deleted_time: 1000,
|
|
|
|
parent_id: '1',
|
2024-03-14 20:30:49 +02:00
|
|
|
id: 'b',
|
2024-03-02 16:25:27 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
deleted_time: 0,
|
2024-03-14 20:30:49 +02:00
|
|
|
id: '1',
|
2024-03-02 16:25:27 +02:00
|
|
|
},
|
|
|
|
getTrashFolderId(),
|
|
|
|
],
|
|
|
|
[
|
|
|
|
{
|
|
|
|
deleted_time: 1000,
|
|
|
|
parent_id: '1',
|
2024-03-14 20:30:49 +02:00
|
|
|
id: 'a',
|
2024-03-02 16:25:27 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
deleted_time: 1000,
|
2024-03-14 20:30:49 +02:00
|
|
|
id: '1',
|
2024-03-02 16:25:27 +02:00
|
|
|
},
|
|
|
|
'1',
|
|
|
|
],
|
2024-03-29 14:11:15 +02:00
|
|
|
|
|
|
|
// should show non-deleted conflicts in the conflicts folder
|
|
|
|
[
|
|
|
|
{
|
|
|
|
deleted_time: 0,
|
|
|
|
is_conflict: 1,
|
|
|
|
parent_id: Folder.conflictFolderId(),
|
|
|
|
id: 'b',
|
|
|
|
},
|
|
|
|
Folder.conflictFolder(),
|
|
|
|
Folder.conflictFolderId(),
|
|
|
|
],
|
|
|
|
// should show deleted conflicts in the trash folder
|
|
|
|
[
|
|
|
|
{
|
|
|
|
deleted_time: 1000,
|
|
|
|
is_conflict: 1,
|
|
|
|
parent_id: Folder.conflictFolderId(),
|
|
|
|
id: 'someidhere',
|
|
|
|
},
|
|
|
|
Folder.conflictFolder(),
|
|
|
|
getTrashFolderId(),
|
|
|
|
],
|
2024-03-14 20:30:49 +02:00
|
|
|
])('should return the display parent ID (case %#)', (item, itemParent, expected) => {
|
|
|
|
const defaultProps = { type_: ModelType.Folder };
|
|
|
|
const actual = getDisplayParentId({ ...defaultProps, ...item }, { ...defaultProps, ...itemParent });
|
2024-03-02 16:25:27 +02:00
|
|
|
expect(actual).toBe(expected);
|
|
|
|
});
|
|
|
|
});
|