@@ -11,6 +11,7 @@ describe('File creation', () => {
1111 test ( 'Valid dav file' , ( ) => {
1212 const file = new File ( {
1313 source : 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg' ,
14+ root : '/files/emma/Photos' ,
1415 mime : 'image/jpeg' ,
1516 owner : 'emma' ,
1617 mtime : new Date ( Date . UTC ( 2023 , 0 , 1 , 0 , 0 , 0 ) ) ,
@@ -45,9 +46,9 @@ describe('File creation', () => {
4546 test ( 'Valid dav file with root' , ( ) => {
4647 const file = new File ( {
4748 source : 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg' ,
49+ root : '/files/emma' ,
4850 mime : 'image/jpeg' ,
4951 owner : 'emma' ,
50- root : '/files/emma' ,
5152 } )
5253
5354 expect ( file ) . toBeInstanceOf ( File )
@@ -72,6 +73,7 @@ describe('File creation', () => {
7273 test ( 'Valid remote file' , ( ) => {
7374 const file = new File ( {
7475 source : 'https://domain.com/Photos/picture.jpg' ,
76+ root : '/' ,
7577 mime : 'image/jpeg' ,
7678 owner : null ,
7779 } )
@@ -89,7 +91,7 @@ describe('File creation', () => {
8991 expect ( file . basename ) . toBe ( 'picture.jpg' )
9092 expect ( file . extension ) . toBe ( '.jpg' )
9193 expect ( file . dirname ) . toBe ( '/Photos' )
92- expect ( file . root ) . toBeNull ( )
94+ expect ( file . root ) . toBe ( '/' )
9395 expect ( file . isDavResource ) . toBe ( false )
9496 expect ( file . permissions ) . toBe ( Permission . READ )
9597 } )
@@ -98,45 +100,48 @@ describe('File creation', () => {
98100describe ( 'File data change' , ( ) => {
99101 test ( 'Rename a file' , ( ) => {
100102 const file = new File ( {
101- source : 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg' ,
103+ source : 'https://cloud.domain.com/remote.php/dav/files/emma/picture.jpg' ,
104+ root : '/files/emma' ,
102105 mime : 'image/jpeg' ,
103106 owner : 'emma' ,
104107 } )
105108
106109 expect ( file . basename ) . toBe ( 'picture.jpg' )
107110 expect ( file . dirname ) . toBe ( '/' )
108- expect ( file . root ) . toBe ( '/files/emma/Photos ' )
111+ expect ( file . root ) . toBe ( '/files/emma' )
109112
110113 file . rename ( 'picture-old.jpg' )
111114
112115 expect ( file . basename ) . toBe ( 'picture-old.jpg' )
113116 expect ( file . dirname ) . toBe ( '/' )
114- expect ( file . source ) . toBe ( 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/ picture-old.jpg' )
115- expect ( file . root ) . toBe ( '/files/emma/Photos ' )
117+ expect ( file . source ) . toBe ( 'https://cloud.domain.com/remote.php/dav/files/emma/picture-old.jpg' )
118+ expect ( file . root ) . toBe ( '/files/emma' )
116119 } )
117120
118121 test ( 'Moving a file' , ( ) => {
119122 const file = new File ( {
120123 source : 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg' ,
124+ root : '/files/emma' ,
121125 mime : 'image/jpeg' ,
122126 owner : 'emma' ,
123127 } )
124128
125129 expect ( file . basename ) . toBe ( 'picture.jpg' )
126- expect ( file . dirname ) . toBe ( '/' )
127- expect ( file . root ) . toBe ( '/files/emma/Photos ' )
130+ expect ( file . dirname ) . toBe ( '/Photos ' )
131+ expect ( file . root ) . toBe ( '/files/emma' )
128132
129133 file . move ( 'https://cloud.domain.com/remote.php/dav/files/emma/Pictures/picture-old.jpg' )
130134
131135 expect ( file . basename ) . toBe ( 'picture-old.jpg' )
132- expect ( file . dirname ) . toBe ( '/' )
136+ expect ( file . dirname ) . toBe ( '/Pictures ' )
133137 expect ( file . source ) . toBe ( 'https://cloud.domain.com/remote.php/dav/files/emma/Pictures/picture-old.jpg' )
134- expect ( file . root ) . toBe ( '/files/emma/Pictures ' )
138+ expect ( file . root ) . toBe ( '/files/emma' )
135139 } )
136140
137141 test ( 'Moving a file to an invalid destination throws' , ( ) => {
138142 const file = new File ( {
139143 source : 'https://cloud.domain.com/remote.php/dav/files/emma/Photos/picture.jpg' ,
144+ root : '/files/emma' ,
140145 mime : 'image/jpeg' ,
141146 owner : 'emma' ,
142147 mtime : new Date ( Date . UTC ( 2023 , 0 , 1 , 0 , 0 , 0 ) ) ,
@@ -184,6 +189,7 @@ describe('Altering attributes does NOT updates mtime', () => {
184189 test ( 'mtime is updated on existing attribute' , ( ) => {
185190 const file = new File ( {
186191 source : 'https://cloud.domain.com/remote.php/dav/files/emma' ,
192+ root : '/files/emma' ,
187193 mime : 'image/jpeg' ,
188194 owner : 'emma' ,
189195 mtime : new Date ( Date . UTC ( 1990 , 0 , 1 , 0 , 0 , 0 ) ) ,
@@ -202,6 +208,7 @@ describe('Altering attributes does NOT updates mtime', () => {
202208 test ( 'mtime is NOT updated on new attribute' , ( ) => {
203209 const file = new File ( {
204210 source : 'https://cloud.domain.com/remote.php/dav/files/emma' ,
211+ root : '/files/emma' ,
205212 mime : 'image/jpeg' ,
206213 owner : 'emma' ,
207214 mtime : new Date ( Date . UTC ( 1990 , 0 , 1 , 0 , 0 , 0 ) ) ,
@@ -217,6 +224,7 @@ describe('Altering attributes does NOT updates mtime', () => {
217224 test ( 'mtime is NOT updated on deleted attribute' , ( ) => {
218225 const file = new File ( {
219226 source : 'https://cloud.domain.com/remote.php/dav/files/emma' ,
227+ root : '/files/emma' ,
220228 mime : 'image/jpeg' ,
221229 owner : 'emma' ,
222230 mtime : new Date ( Date . UTC ( 1990 , 0 , 1 , 0 , 0 , 0 ) ) ,
@@ -235,6 +243,7 @@ describe('Altering attributes does NOT updates mtime', () => {
235243 test ( 'mtime is NOT updated if not initially defined' , ( ) => {
236244 const file = new File ( {
237245 source : 'https://cloud.domain.com/remote.php/dav/files/emma' ,
246+ root : '/files/emma' ,
238247 mime : 'image/jpeg' ,
239248 owner : 'emma' ,
240249 permissions : Permission . READ ,
@@ -254,6 +263,7 @@ describe('Altering top-level properties updates mtime', () => {
254263 test ( 'mtime is updated on permissions change' , ( ) => {
255264 const file = new File ( {
256265 source : 'https://cloud.domain.com/remote.php/dav/files/emma' ,
266+ root : '/files/emma' ,
257267 mime : 'image/jpeg' ,
258268 owner : 'emma' ,
259269 mtime : new Date ( Date . UTC ( 1990 , 0 , 1 , 0 , 0 , 0 ) ) ,
@@ -271,6 +281,7 @@ describe('Altering top-level properties updates mtime', () => {
271281 test ( 'mtime is updated on size change' , ( ) => {
272282 const file = new File ( {
273283 source : 'https://cloud.domain.com/remote.php/dav/files/emma' ,
284+ root : '/files/emma' ,
274285 mime : 'image/jpeg' ,
275286 owner : 'emma' ,
276287 mtime : new Date ( Date . UTC ( 1990 , 0 , 1 , 0 , 0 , 0 ) ) ,
0 commit comments