55
66import type { Attribute , NodeData } from '../../lib/node/index.ts'
77
8- import { describe , expect , test , vi } from 'vitest'
8+ import { describe , expect , test } from 'vitest'
99import { File , Folder , NodeStatus } from '../../lib/node/index.ts'
1010import { Permission } from '../../lib/permissions.ts'
1111
@@ -251,21 +251,6 @@ describe('Permissions attribute', () => {
251251} )
252252
253253describe ( 'Displayname attribute' , ( ) => {
254- test ( 'legacy displayname attribute' , ( ) => {
255- // TODO: This logic can be removed with next major release (v4)
256- const file = new File ( {
257- source : 'https://cloud.domain.com/remote.php/dav/picture.jpg' ,
258- mime : 'image/jpeg' ,
259- owner : 'emma' ,
260- attributes : {
261- displayname : 'image.png' ,
262- } ,
263- } )
264- expect ( file . basename ) . toBe ( 'picture.jpg' )
265- expect ( file . displayname ) . toBe ( 'image.png' )
266- expect ( file . attributes . displayname ) . toBe ( 'image.png' )
267- } )
268-
269254 test ( 'Read displayname attribute' , ( ) => {
270255 const file = new File ( {
271256 source : 'https://cloud.domain.com/remote.php/dav/picture.jpg' ,
@@ -820,26 +805,9 @@ describe('Attributes update', () => {
820805 } )
821806
822807 expect ( file . attributes ?. etag ) . toBe ( '5678' )
823- expect ( file . attributes ?. size ) . toBe ( 9999 )
824- expect ( file . attributes ?. owner ) . toBe ( 'emma' )
825- expect ( file . attributes ?. fileid ) . toBeUndefined ( )
826- } )
827-
828- test ( 'Deprecated access to toplevel attributes' , ( ) => {
829- const spy = vi . spyOn ( window . console , 'warn' )
830- const file = new File ( {
831- source : 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg' ,
832- mime : 'image/jpeg' ,
833- owner : 'emma' ,
834- size : 9999 ,
835- attributes : {
836- etag : '1234' ,
837- size : 9999 ,
838- } ,
839- } )
840-
841- expect ( file . attributes . size ) . toBe ( 9999 )
842- expect ( spy ) . toBeCalledTimes ( 1 )
808+ expect ( file ?. size ) . toBe ( 9999 )
809+ expect ( file ?. owner ) . toBe ( 'emma' )
810+ expect ( file ?. fileid ) . toBeUndefined ( )
843811 } )
844812
845813 test ( 'Changing a protected attributes is not possible' , ( ) => {
@@ -853,9 +821,10 @@ describe('Attributes update', () => {
853821 } )
854822
855823 // We can not update the owner
856- expect ( ( ) => { file . attributes . owner = 'admin' } ) . toThrowError ( )
824+ // @ts -expect-error owner is a read-only property
825+ expect ( ( ) => { file . owner = 'admin' } ) . toThrowError ( )
857826 // The owner is still the original one
858- expect ( file . attributes ?. owner ) . toBe ( 'emma' )
827+ expect ( file ?. owner ) . toBe ( 'emma' )
859828 } )
860829
861830} )
0 commit comments