33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55
6- import type { Node } from '../../lib/node/index.ts'
6+ import type { Folder , Node } from '../../lib/node/index.ts'
77import type { View } from '../../lib/navigation/view.ts'
88
99import { beforeEach , describe , expect , test , vi } from 'vitest'
1010import { getFileActions , registerFileAction , FileAction , DefaultType , FileActionData } from '../../lib/actions/index.ts'
1111import logger from '../../lib/utils/logger.ts'
1212
13+ const folder = { } as Folder
14+ const view = { } as View
1315describe ( 'FileActions init' , ( ) => {
1416
1517 beforeEach ( ( ) => {
@@ -34,8 +36,8 @@ describe('FileActions init', () => {
3436 } )
3537
3638 expect ( action . id ) . toBe ( 'test' )
37- expect ( action . displayName ( [ ] , { } as unknown as View ) ) . toBe ( 'Test' )
38- expect ( action . iconSvgInline ( [ ] , { } as unknown as View ) ) . toBe ( '<svg></svg>' )
39+ expect ( action . displayName ( { view , folder , nodes : [ ] , content : [ ] } ) ) . toBe ( 'Test' )
40+ expect ( action . iconSvgInline ( { view , folder , nodes : [ ] , content : [ ] } ) ) . toBe ( '<svg></svg>' )
3941
4042 registerFileAction ( action )
4143
@@ -244,18 +246,20 @@ describe('FileActions creation', () => {
244246 } ,
245247 } )
246248
249+ const node = { } as Node
250+
247251 expect ( action . id ) . toBe ( 'test' )
248- expect ( action . displayName ( [ ] , { } as unknown as View ) ) . toBe ( 'Test' )
249- expect ( action . title ?.( [ ] , { } as unknown as View ) ) . toBe ( 'Test title' )
250- expect ( action . iconSvgInline ( [ ] , { } as unknown as View ) ) . toBe ( '<svg></svg>' )
251- await expect ( action . exec ( { } as unknown as Node , { } as unknown as View , '/' ) ) . resolves . toBe ( true )
252- await expect ( action . execBatch ?.( [ ] , { } as unknown as View , '/' ) ) . resolves . toStrictEqual ( [ true ] )
253- expect ( action . enabled ?.( [ ] , { } as unknown as View ) ) . toBe ( true )
252+ expect ( action . displayName ( { view , folder , nodes : [ ] , content : [ ] } ) ) . toBe ( 'Test' )
253+ expect ( action . title ?.( { view , folder , nodes : [ ] , content : [ ] } ) ) . toBe ( 'Test title' )
254+ expect ( action . iconSvgInline ( { view , folder , nodes : [ ] , content : [ ] } ) ) . toBe ( '<svg></svg>' )
255+ await expect ( action . exec ( { view , folder , nodes : [ node ] , content : [ ] } ) ) . resolves . toBe ( true )
256+ await expect ( action . execBatch ?.( { view , folder , nodes : [ ] , content : [ ] } ) ) . resolves . toStrictEqual ( [ true ] )
257+ expect ( action . enabled ?.( { view , folder , nodes : [ ] , content : [ ] } ) ) . toBe ( true )
254258 expect ( action . order ) . toBe ( 100 )
255259 expect ( action . parent ) . toBe ( '123' )
256260 expect ( action . destructive ) . toBe ( true )
257261 expect ( action . default ) . toBe ( DefaultType . DEFAULT )
258- expect ( action . inline ?.( { } as unknown as Node , { } as unknown as View ) ) . toBe ( true )
259- expect ( ( await action . renderInline ?.( { } as unknown as Node , { } as unknown as View ) ) ?. outerHTML ) . toBe ( '<span>test</span>' )
262+ expect ( action . inline ?.( { view , folder , nodes : [ ] , content : [ ] } ) ) . toBe ( true )
263+ expect ( ( await action . renderInline ?.( { view , folder , nodes : [ ] , content : [ ] } ) ) ?. outerHTML ) . toBe ( '<span>test</span>' )
260264 } )
261265} )
0 commit comments