@@ -77,6 +77,51 @@ describe('FileId attribute', () => {
7777 } )
7878} )
7979
80+ describe ( 'Id attribute' , ( ) => {
81+ test ( 'Id undefined' , ( ) => {
82+ const file = new File ( {
83+ source : 'https://cloud.domain.com/remote.php/dav/files/emma/picture.jpg' ,
84+ root : '/files/emma' ,
85+ mime : 'image/jpeg' ,
86+ owner : 'emma' ,
87+ } )
88+ expect ( file . id ) . toBeUndefined ( )
89+ } )
90+
91+ test ( 'id definition' , ( ) => {
92+ const file = new File ( {
93+ source : 'https://cloud.domain.com/remote.php/dav/files/emma/picture.jpg' ,
94+ root : '/files/emma' ,
95+ mime : 'image/jpeg' ,
96+ owner : 'emma' ,
97+ id : '1234' ,
98+ } )
99+ expect ( file . id ) . toBe ( '1234' )
100+ } )
101+
102+ test ( 'Legacy id definition' , ( ) => {
103+ const file = new File ( {
104+ source : 'https://cloud.domain.com/remote.php/dav/files/emma/picture.jpg' ,
105+ root : '/files/emma' ,
106+ mime : 'image/jpeg' ,
107+ owner : 'emma' ,
108+ id : 1234 ,
109+ } )
110+ expect ( file . id ) . toBe ( '1234' )
111+ } )
112+
113+ test ( 'Legacy failed node id' , ( ) => {
114+ const file = new File ( {
115+ source : 'https://cloud.domain.com/remote.php/dav/files/emma/picture.jpg' ,
116+ root : '/files/emma' ,
117+ mime : 'image/jpeg' ,
118+ owner : 'emma' ,
119+ id : - 1 ,
120+ } )
121+ expect ( file . id ) . toBeUndefined ( )
122+ } )
123+ } )
124+
80125describe ( 'Mime attribute' , ( ) => {
81126 test ( 'Mime definition' , ( ) => {
82127 const file = new File ( {
@@ -304,7 +349,7 @@ describe('Sanity checks', () => {
304349 root : '/files/emma' ,
305350 mime : 'image/jpeg' ,
306351 owner : 'emma' ,
307- id : '1234' as unknown as number ,
352+ id : true as unknown as number ,
308353 } ) ) . toThrowError ( 'Invalid id type of value' )
309354 } )
310355
0 commit comments