33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55
6- import type { Folder , Node } from '../../lib/node /index.ts'
6+ import type { FileActionData } from '../../lib/actions /index.ts'
77import type { View } from '../../lib/navigation/view.ts'
8+ import type { Folder , Node } from '../../lib/node/index.ts'
89
910import { beforeEach , describe , expect , test , vi } from 'vitest'
10- import { getFileActions , registerFileAction , FileAction , DefaultType , FileActionData } from '../../lib/actions/index.ts'
11+ import { DefaultType , FileAction , getFileActions , registerFileAction } from '../../lib/actions/index.ts'
1112import logger from '../../lib/utils/logger.ts'
1213
1314const folder = { } as Folder
1415const view = { } as View
1516describe ( 'FileActions init' , ( ) => {
16-
1717 beforeEach ( ( ) => {
1818 delete window . _nc_fileactions
1919 } )
@@ -101,17 +101,15 @@ describe('Invalid FileAction creation', () => {
101101 displayName : ( ) => 'Test' ,
102102 iconSvgInline : ( ) => '<svg></svg>' ,
103103 exec : async ( ) => true ,
104- } as unknown as FileAction ) ,
105- ) . toThrowError ( 'Invalid id' )
104+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid id' )
106105 } )
107106 test ( 'Invalid displayName' , ( ) => {
108107 expect ( ( ) => new FileAction ( {
109108 id : 'test' ,
110109 displayName : 'Test' ,
111110 iconSvgInline : ( ) => '<svg></svg>' ,
112111 exec : async ( ) => true ,
113- } as unknown as FileAction ) ,
114- ) . toThrowError ( 'Invalid displayName function' )
112+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid displayName function' )
115113 } )
116114 test ( 'Invalid title' , ( ) => {
117115 expect ( ( ) => new FileAction ( {
@@ -120,26 +118,23 @@ describe('Invalid FileAction creation', () => {
120118 title : 'Test' ,
121119 iconSvgInline : ( ) => '<svg></svg>' ,
122120 exec : async ( ) => true ,
123- } as unknown as FileAction ) ,
124- ) . toThrowError ( 'Invalid title function' )
121+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid title function' )
125122 } )
126123 test ( 'Invalid iconSvgInline' , ( ) => {
127124 expect ( ( ) => new FileAction ( {
128125 id : 'test' ,
129126 displayName : ( ) => 'Test' ,
130127 iconSvgInline : '<svg></svg>' ,
131128 exec : async ( ) => true ,
132- } as unknown as FileAction ) ,
133- ) . toThrowError ( 'Invalid iconSvgInline function' )
129+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid iconSvgInline function' )
134130 } )
135131 test ( 'Invalid exec' , ( ) => {
136132 expect ( ( ) => new FileAction ( {
137133 id : 'test' ,
138134 displayName : ( ) => 'Test' ,
139135 iconSvgInline : ( ) => '<svg></svg>' ,
140136 exec : false ,
141- } as unknown as FileAction ) ,
142- ) . toThrowError ( 'Invalid exec function' )
137+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid exec function' )
143138 } )
144139 test ( 'Invalid enabled' , ( ) => {
145140 expect ( ( ) => new FileAction ( {
@@ -148,8 +143,7 @@ describe('Invalid FileAction creation', () => {
148143 iconSvgInline : ( ) => '<svg></svg>' ,
149144 exec : async ( ) => true ,
150145 enabled : false ,
151- } as unknown as FileAction ) ,
152- ) . toThrowError ( 'Invalid enabled function' )
146+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid enabled function' )
153147 } )
154148 test ( 'Invalid execBatch' , ( ) => {
155149 expect ( ( ) => new FileAction ( {
@@ -158,8 +152,7 @@ describe('Invalid FileAction creation', () => {
158152 iconSvgInline : ( ) => '<svg></svg>' ,
159153 exec : async ( ) => true ,
160154 execBatch : false ,
161- } as unknown as FileAction ) ,
162- ) . toThrowError ( 'Invalid execBatch function' )
155+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid execBatch function' )
163156 } )
164157 test ( 'Invalid order' , ( ) => {
165158 expect ( ( ) => new FileAction ( {
@@ -168,8 +161,7 @@ describe('Invalid FileAction creation', () => {
168161 iconSvgInline : ( ) => '<svg></svg>' ,
169162 exec : async ( ) => true ,
170163 order : 'invalid' ,
171- } as unknown as FileAction ) ,
172- ) . toThrowError ( 'Invalid order' )
164+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid order' )
173165 } )
174166 test ( 'Invalid parent' , ( ) => {
175167 expect ( ( ) => new FileAction ( {
@@ -178,8 +170,7 @@ describe('Invalid FileAction creation', () => {
178170 iconSvgInline : ( ) => '<svg></svg>' ,
179171 exec : async ( ) => true ,
180172 parent : true ,
181- } as unknown as FileAction ) ,
182- ) . toThrowError ( 'Invalid parent' )
173+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid parent' )
183174 } )
184175 test ( 'Invalid default' , ( ) => {
185176 expect ( ( ) => new FileAction ( {
@@ -188,8 +179,7 @@ describe('Invalid FileAction creation', () => {
188179 iconSvgInline : ( ) => '<svg></svg>' ,
189180 exec : async ( ) => true ,
190181 default : 'invalid' ,
191- } as unknown as FileAction ) ,
192- ) . toThrowError ( 'Invalid default' )
182+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid default' )
193183 } )
194184 test ( 'Invalid destructives' , ( ) => {
195185 expect ( ( ) => new FileAction ( {
@@ -198,8 +188,7 @@ describe('Invalid FileAction creation', () => {
198188 iconSvgInline : ( ) => '<svg></svg>' ,
199189 exec : async ( ) => true ,
200190 destructive : 'false' ,
201- } as unknown as FileActionData ) ,
202- ) . toThrowError ( 'Invalid destructive' )
191+ } as unknown as FileActionData ) ) . toThrowError ( 'Invalid destructive' )
203192 } )
204193 test ( 'Invalid inline' , ( ) => {
205194 expect ( ( ) => new FileAction ( {
@@ -208,8 +197,7 @@ describe('Invalid FileAction creation', () => {
208197 iconSvgInline : ( ) => '<svg></svg>' ,
209198 exec : async ( ) => true ,
210199 inline : true ,
211- } as unknown as FileAction ) ,
212- ) . toThrowError ( 'Invalid inline function' )
200+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid inline function' )
213201
214202 expect ( ( ) => new FileAction ( {
215203 id : 'test' ,
@@ -218,8 +206,7 @@ describe('Invalid FileAction creation', () => {
218206 exec : async ( ) => true ,
219207 inline : ( ) => true ,
220208 renderInline : false ,
221- } as unknown as FileAction ) ,
222- ) . toThrowError ( 'Invalid renderInline function' )
209+ } as unknown as FileAction ) ) . toThrowError ( 'Invalid renderInline function' )
223210 } )
224211} )
225212
0 commit comments