@@ -11,15 +11,15 @@ import { defineComponent, h, nextTick, ref, toRef } from 'vue'
1111import { useDAVFiles } from './dav.ts'
1212
1313const nextcloudFiles = vi . hoisted ( ( ) => ( {
14- davGetClient : vi . fn ( ) ,
15- davRootPath : '/root/uid' ,
16- davRemoteURL : 'https://localhost/remote.php/dav' ,
17- davResultToNode : vi . fn ( ) ,
18- davGetDefaultPropfind : vi . fn ( ) ,
19- davGetRecentSearch : ( time : number ) => `recent ${ time } ` ,
14+ getClient : vi . fn ( ) ,
15+ defaultRootPath : '/root/uid' ,
16+ defaultRemoteURL : 'https://localhost/remote.php/dav' ,
17+ resultToNode : vi . fn ( ) ,
18+ getDefaultPropfind : vi . fn ( ) ,
19+ getRecentSearch : ( time : number ) => `recent ${ time } ` ,
2020 getFavoriteNodes : vi . fn ( ) ,
2121} ) )
22- vi . mock ( '@nextcloud/files' , ( ) => nextcloudFiles )
22+ vi . mock ( '@nextcloud/files/dav ' , ( ) => nextcloudFiles )
2323
2424// eslint-disable-next-line @typescript-eslint/no-empty-object-type
2525function waitLoaded ( vm : ComponentPublicInstance < { } , { isLoading : boolean } > ) {
@@ -68,7 +68,7 @@ describe('dav composable', () => {
6868 const client = {
6969 getDirectoryContents : vi . fn ( ( ) => ( { data : [ ] } ) ) ,
7070 }
71- nextcloudFiles . davGetClient . mockImplementationOnce ( ( ) => client )
71+ nextcloudFiles . getClient . mockImplementationOnce ( ( ) => client )
7272
7373 const vue = shallowMount ( TestComponent , {
7474 props : {
@@ -80,7 +80,7 @@ describe('dav composable', () => {
8080 // Loading is set to true
8181 expect ( vue . vm . isLoading ) . toBe ( true )
8282 // Dav client for dav remote url is gathered
83- expect ( nextcloudFiles . davGetClient ) . toBeCalled ( )
83+ expect ( nextcloudFiles . getClient ) . toBeCalled ( )
8484 // files is an empty array
8585 expect ( Array . isArray ( vue . vm . files ) ) . toBe ( true )
8686 expect ( vue . vm . files . length ) . toBe ( 0 )
@@ -92,8 +92,8 @@ describe('dav composable', () => {
9292 const client = {
9393 getDirectoryContents : vi . fn ( ( ) => ( { data : [ '1' , '2' ] } ) ) ,
9494 }
95- nextcloudFiles . davGetClient . mockImplementationOnce ( ( ) => client )
96- nextcloudFiles . davResultToNode . mockImplementation ( ( v ) => `node ${ v } ` )
95+ nextcloudFiles . getClient . mockImplementationOnce ( ( ) => client )
96+ nextcloudFiles . resultToNode . mockImplementation ( ( v ) => `node ${ v } ` )
9797
9898 const vue = shallowMount ( TestComponent , {
9999 props : {
@@ -114,7 +114,7 @@ describe('dav composable', () => {
114114 // eslint-disable-next-line @typescript-eslint/no-unused-vars
115115 getDirectoryContents : vi . fn ( ( _path : string ) => ( { data : [ ] } ) ) ,
116116 }
117- nextcloudFiles . davGetClient . mockImplementationOnce ( ( ) => client )
117+ nextcloudFiles . getClient . mockImplementationOnce ( ( ) => client )
118118
119119 const vue = shallowMount ( TestComponent , {
120120 props : {
@@ -128,13 +128,13 @@ describe('dav composable', () => {
128128 await waitLoaded ( vue . vm )
129129
130130 expect ( client . getDirectoryContents ) . toBeCalledTimes ( 1 )
131- expect ( client . getDirectoryContents . mock . calls [ 0 ] ! [ 0 ] ) . toBe ( `${ nextcloudFiles . davRootPath } /` )
131+ expect ( client . getDirectoryContents . mock . calls [ 0 ] ! [ 0 ] ) . toBe ( `${ nextcloudFiles . defaultRootPath } /` )
132132
133133 vue . setProps ( { currentPath : '/other' } )
134134 await waitLoaded ( vue . vm )
135135
136136 expect ( client . getDirectoryContents ) . toBeCalledTimes ( 2 )
137- expect ( client . getDirectoryContents . mock . calls [ 1 ] ! [ 0 ] ) . toBe ( `${ nextcloudFiles . davRootPath } /other` )
137+ expect ( client . getDirectoryContents . mock . calls [ 1 ] ! [ 0 ] ) . toBe ( `${ nextcloudFiles . defaultRootPath } /other` )
138138 } )
139139
140140 it ( 'reloads on view change' , async ( ) => {
@@ -143,7 +143,7 @@ describe('dav composable', () => {
143143 getDirectoryContents : vi . fn ( ( _path : string ) => ( { data : [ ] } ) ) ,
144144 search : vi . fn ( ( ) => ( { data : { results : [ ] , truncated : false } } ) ) ,
145145 }
146- nextcloudFiles . davGetClient . mockImplementationOnce ( ( ) => client )
146+ nextcloudFiles . getClient . mockImplementationOnce ( ( ) => client )
147147
148148 const vue = shallowMount ( TestComponent , {
149149 props : {
@@ -158,7 +158,7 @@ describe('dav composable', () => {
158158
159159 expect ( client . search ) . not . toBeCalled ( )
160160 expect ( client . getDirectoryContents ) . toBeCalledTimes ( 1 )
161- expect ( client . getDirectoryContents . mock . calls [ 0 ] ! [ 0 ] ) . toBe ( `${ nextcloudFiles . davRootPath } /` )
161+ expect ( client . getDirectoryContents . mock . calls [ 0 ] ! [ 0 ] ) . toBe ( `${ nextcloudFiles . defaultRootPath } /` )
162162
163163 vue . setProps ( { currentView : 'recent' } )
164164 await waitLoaded ( vue . vm )
@@ -173,15 +173,15 @@ describe('dav composable', () => {
173173 stat : vi . fn ( ( v ) => ( { data : { path : v } } ) ) ,
174174 createDirectory : vi . fn ( ( ) => { } ) ,
175175 }
176- nextcloudFiles . davGetClient . mockImplementation ( ( ) => client )
177- nextcloudFiles . davResultToNode . mockImplementation ( ( v ) => v )
176+ nextcloudFiles . getClient . mockImplementation ( ( ) => client )
177+ nextcloudFiles . resultToNode . mockImplementation ( ( v ) => v )
178178
179179 const { createDirectory } = useDAVFiles ( ref ( 'files' ) , ref ( '/foo/' ) )
180180
181181 const node = await createDirectory ( 'my-name' )
182- expect ( node ) . toEqual ( { path : `${ nextcloudFiles . davRootPath } /foo/my-name` } )
183- expect ( client . stat ) . toBeCalledWith ( `${ nextcloudFiles . davRootPath } /foo/my-name` , { details : true } )
184- expect ( client . createDirectory ) . toBeCalledWith ( `${ nextcloudFiles . davRootPath } /foo/my-name` )
182+ expect ( node ) . toEqual ( { path : `${ nextcloudFiles . defaultRootPath } /foo/my-name` } )
183+ expect ( client . stat ) . toBeCalledWith ( `${ nextcloudFiles . defaultRootPath } /foo/my-name` , { details : true } )
184+ expect ( client . createDirectory ) . toBeCalledWith ( `${ nextcloudFiles . defaultRootPath } /foo/my-name` )
185185 } )
186186
187187 it ( 'loadFiles work' , async ( ) => {
@@ -190,8 +190,8 @@ describe('dav composable', () => {
190190 getDirectoryContents : vi . fn ( ( ) => ( { data : [ ] } ) ) ,
191191 search : vi . fn ( ( ) => ( { data : { results : [ ] , truncated : false } } ) ) ,
192192 }
193- nextcloudFiles . davGetClient . mockImplementationOnce ( ( ) => client )
194- nextcloudFiles . davResultToNode . mockImplementationOnce ( ( v ) => v )
193+ nextcloudFiles . getClient . mockImplementationOnce ( ( ) => client )
194+ nextcloudFiles . resultToNode . mockImplementationOnce ( ( v ) => v )
195195 nextcloudFiles . getFavoriteNodes . mockImplementationOnce ( ( ) => Promise . resolve ( [ ] ) )
196196
197197 const view = ref < 'files' | 'recent' | 'favorites' > ( 'files' )
@@ -201,7 +201,7 @@ describe('dav composable', () => {
201201 expect ( isLoading . value ) . toBe ( true )
202202 await loadFiles ( )
203203 expect ( isLoading . value ) . toBe ( false )
204- expect ( client . getDirectoryContents ) . toBeCalledWith ( `${ nextcloudFiles . davRootPath } /` , expect . objectContaining ( { details : true } ) )
204+ expect ( client . getDirectoryContents ) . toBeCalledWith ( `${ nextcloudFiles . defaultRootPath } /` , expect . objectContaining ( { details : true } ) )
205205
206206 view . value = 'recent'
207207 await waitRefLoaded ( isLoading )
@@ -218,8 +218,8 @@ describe('dav composable', () => {
218218 getDirectoryContents : vi . fn ( ( ) => ( { data : [ ] } ) ) ,
219219 search : vi . fn ( ( ) => ( { data : { results : [ ] , truncated : false } } ) ) ,
220220 }
221- nextcloudFiles . davGetClient . mockImplementationOnce ( ( ) => client )
222- nextcloudFiles . davResultToNode . mockImplementationOnce ( ( v ) => v )
221+ nextcloudFiles . getClient . mockImplementationOnce ( ( ) => client )
222+ nextcloudFiles . resultToNode . mockImplementationOnce ( ( v ) => v )
223223
224224 const view = ref < 'files' | 'recent' | 'favorites' > ( 'files' )
225225 const path = ref ( '/' )
0 commit comments