33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55import { action } from './renameAction'
6- import { File , Permission , View , FileAction } from '@nextcloud/files'
6+ import { File , Folder , Permission , View , FileAction } from '@nextcloud/files'
77import * as eventBus from '@nextcloud/event-bus'
8- import { describe , expect , test , vi } from 'vitest'
8+ import { describe , expect , test , vi , beforeEach } from 'vitest'
9+ import { useFilesStore } from '../store/files'
10+ import { getPinia } from '../store/index.ts'
911
1012const view = {
1113 id : 'files' ,
1214 name : 'Files' ,
1315} as View
1416
17+ beforeEach ( ( ) => {
18+ const root = new Folder ( { owner : 'test' , source : 'https://cloud.domain.com/remote.php/dav/files/admin/' , id : 1 , permissions : Permission . CREATE } )
19+ const files = useFilesStore ( getPinia ( ) )
20+ files . setRoot ( { service : 'files' , root } )
21+ } )
22+
1523describe ( 'Rename action conditions tests' , ( ) => {
1624 test ( 'Default values' , ( ) => {
1725 expect ( action ) . toBeInstanceOf ( FileAction )
@@ -26,7 +34,7 @@ describe('Rename action conditions tests', () => {
2634describe ( 'Rename action enabled tests' , ( ) => {
2735 test ( 'Enabled for node with UPDATE permission' , ( ) => {
2836 const file = new File ( {
29- id : 1 ,
37+ id : 2 ,
3038 source : 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt' ,
3139 owner : 'admin' ,
3240 mime : 'text/plain' ,
@@ -39,7 +47,7 @@ describe('Rename action enabled tests', () => {
3947
4048 test ( 'Disabled for node without DELETE permission' , ( ) => {
4149 const file = new File ( {
42- id : 1 ,
50+ id : 2 ,
4351 source : 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt' ,
4452 owner : 'admin' ,
4553 mime : 'text/plain' ,
@@ -54,13 +62,13 @@ describe('Rename action enabled tests', () => {
5462 window . OCA = { Files : { Sidebar : { } } }
5563
5664 const file1 = new File ( {
57- id : 1 ,
65+ id : 2 ,
5866 source : 'https://cloud.domain.com/remote.php/dav/files/admin/foo.txt' ,
5967 owner : 'admin' ,
6068 mime : 'text/plain' ,
6169 } )
6270 const file2 = new File ( {
63- id : 1 ,
71+ id : 2 ,
6472 source : 'https://cloud.domain.com/remote.php/dav/files/admin/bar.txt' ,
6573 owner : 'admin' ,
6674 mime : 'text/plain' ,
@@ -76,7 +84,7 @@ describe('Rename action exec tests', () => {
7684 vi . spyOn ( eventBus , 'emit' )
7785
7886 const file = new File ( {
79- id : 1 ,
87+ id : 2 ,
8088 source : 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt' ,
8189 owner : 'admin' ,
8290 mime : 'text/plain' ,
0 commit comments