@@ -314,9 +314,8 @@ describe('Sanity checks', () => {
314314
315315 test ( 'Invalid source' , ( ) => {
316316 expect ( ( ) => new File ( { } as unknown as NodeData ) ) . toThrowError ( 'Missing mandatory source' )
317- expect ( ( ) => new File ( {
317+ expect ( ( ) => new Folder ( {
318318 source : 'cloud.domain.com/remote.php/dav/Photos' ,
319- mime : 'image/jpeg' ,
320319 owner : 'emma' ,
321320 } ) ) . toThrowError ( 'Invalid source' )
322321 expect ( ( ) => new File ( {
@@ -332,27 +331,41 @@ describe('Sanity checks', () => {
332331 } )
333332
334333 test ( 'Invalid displayname' , ( ) => {
335- expect ( ( ) => new File ( {
334+ expect ( ( ) => new Folder ( {
336335 source : 'https://cloud.domain.com/remote.php/dav/Photos' ,
337- mime : 'image' ,
338336 displayname : true as unknown as string ,
339337 owner : 'emma' ,
340338 } ) ) . toThrowError ( 'Invalid displayname type' )
339+
340+ const file = new Folder ( {
341+ source : 'https://cloud.domain.com/remote.php/dav/Photos' ,
342+ displayname : 'test' ,
343+ owner : 'emma' ,
344+ } )
345+ // @ts -expect-error wrong type error check
346+ expect ( ( ) => file . displayname = true ) . toThrowError ( 'Invalid displayname' )
341347 } )
348+
342349
343350 test ( 'Invalid mtime' , ( ) => {
344351 expect ( ( ) => new File ( {
345- source : 'https://cloud.domain.com/remote.php/dav/Photos' ,
346- mime : 'image' ,
352+ source : 'https://cloud.domain.com/remote.php/dav/Photos/picture.jpg' ,
347353 owner : 'emma' ,
348354 mtime : 'invalid' as unknown as Date ,
349355 } ) ) . toThrowError ( 'Invalid mtime type' )
356+
357+ const file = new File ( {
358+ source : 'https://cloud.domain.com/remote.php/dav/Photos/picture.jpg' ,
359+ owner : 'emma' ,
360+ } )
361+ // @ts -expect-error wrong type error check
362+ expect ( ( ) => file . mtime = 'invalid' ) . toThrowError ( 'Invalid mtime type' )
350363 } )
351364
352365 test ( 'Invalid crtime' , ( ) => {
353366 expect ( ( ) => new File ( {
354- source : 'https://cloud.domain.com/remote.php/dav/Photos' ,
355- mime : 'image' ,
367+ source : 'https://cloud.domain.com/remote.php/dav/Photos/picture.jpg ' ,
368+ mime : 'image/jpeg ' ,
356369 owner : 'emma' ,
357370 crtime : 'invalid' as unknown as Date ,
358371 } ) ) . toThrowError ( 'Invalid crtime type' )
@@ -364,6 +377,15 @@ describe('Sanity checks', () => {
364377 mime : 'image' ,
365378 owner : 'emma' ,
366379 } ) ) . toThrowError ( 'Missing or invalid mandatory mime' )
380+
381+ const file = new File ( {
382+ source : 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg' ,
383+ mime : 'image/jpeg' ,
384+ owner : 'emma' ,
385+ } )
386+ // @ts -expect-error wrong type error check
387+ expect ( ( ) => file . mime = 1234 ) . toThrowError ( 'Missing or invalid mandatory mime' )
388+ expect ( ( ) => file . mime = 'image' ) . toThrowError ( 'Missing or invalid mandatory mime' )
367389 } )
368390
369391 test ( 'Invalid attributes' , ( ) => {
@@ -391,6 +413,14 @@ describe('Sanity checks', () => {
391413 owner : 'emma' ,
392414 size : 'test' as unknown as number ,
393415 } ) ) . toThrowError ( 'Invalid size type' )
416+
417+ const file = new File ( {
418+ source : 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg' ,
419+ mime : 'image/jpeg' ,
420+ owner : 'emma' ,
421+ } )
422+ // @ts -expect-error wrong type error check
423+ expect ( ( ) => file . size = 'test' ) . toThrowError ( 'Invalid size type' )
394424 } )
395425
396426 test ( 'Invalid owner' , ( ) => {
@@ -438,6 +468,15 @@ describe('Sanity checks', () => {
438468 owner : 'emma' ,
439469 status : 'invalid' as unknown as NodeStatus ,
440470 } ) ) . toThrowError ( 'Status must be a valid NodeStatus' )
471+
472+ const file = new File ( {
473+ source : 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg' ,
474+ mime : 'image/jpeg' ,
475+ owner : 'emma' ,
476+ status : NodeStatus . LOCKED ,
477+ } )
478+ // @ts -expect-error wrong type error check
479+ expect ( ( ) => file . status = 'invalid' ) . toThrowError ( 'Status must be a valid NodeStatus' )
441480 } )
442481} )
443482
0 commit comments