diff --git a/__tests__/files/node.spec.ts b/__tests__/files/node.spec.ts index 517ffc803..89fe1917a 100644 --- a/__tests__/files/node.spec.ts +++ b/__tests__/files/node.spec.ts @@ -52,6 +52,17 @@ describe('FileId attribute', () => { expect(file.fileid).toBe(1234) }) + // Mostly used when a node is unavailable + test('FileId negative fallback', () => { + const file = new File({ + source: 'https://cloud.domain.com/remote.php/dav/picture.jpg', + mime: 'image/jpeg', + owner: 'emma', + id: -1234, + }) + expect(file.fileid).toBe(-1234) + }) + test('FileId attributes fallback', () => { const file = new Folder({ source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/', @@ -73,13 +84,6 @@ describe('Sanity checks', () => { owner: 'emma', id: '1234' as unknown as number, })).toThrowError('Invalid id type of value') - - expect(() => new File({ - source: 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg', - mime: 'image/jpeg', - owner: 'emma', - id: -1234, - })).toThrowError('Invalid id type of value') }) test('Invalid source', () => { diff --git a/lib/files/nodeData.ts b/lib/files/nodeData.ts index a2b808f0d..90865edb7 100644 --- a/lib/files/nodeData.ts +++ b/lib/files/nodeData.ts @@ -81,7 +81,7 @@ export const isDavRessource = function(source: string, davService: RegExp): bool * @param davService Pattern to check if source is DAV ressource */ export const validateData = (data: NodeData, davService: RegExp) => { - if (data.id && (typeof data.id !== 'number' || data.id < 0)) { + if (data.id && typeof data.id !== 'number') { throw new Error('Invalid id type of value') }