Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat: provide fileList names as newFileMenu handler argument
Signed-off-by: John Molakvoæ <[email protected]>
  • Loading branch information
skjnldsv committed Aug 29, 2023
commit 137bc2d1ad88bbae184637555256902ff5589a1d
14 changes: 3 additions & 11 deletions __tests__/newFileMenu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ import { NewFileMenu, getNewFileMenu, type Entry } from '../lib/newFileMenu'
import logger from '../lib/utils/logger'
import { Folder, Permission, View } from '../lib'

const view = new View({
id: 'files',
name: 'Files',
icon: '<svg></svg>',
getContents: async () => ({ folder: {}, contents: [] }),
order: 1,
})

describe('NewFileMenu init', () => {
test('Initializing NewFileMenu', () => {
logger.debug = vi.fn()
Expand Down Expand Up @@ -276,7 +268,7 @@ describe('NewFileMenu getEntries filter', () => {
permissions: Permission.ALL,
})

const entries = newFileMenu.getEntries(context, view)
const entries = newFileMenu.getEntries(context)
expect(entries).toHaveLength(2)
expect(entries[0]).toBe(entry1)
expect(entries[1]).toBe(entry2)
Expand Down Expand Up @@ -312,7 +304,7 @@ describe('NewFileMenu getEntries filter', () => {
permissions: Permission.READ,
})

const entries = newFileMenu.getEntries(context, view)
const entries = newFileMenu.getEntries(context)
expect(entries).toHaveLength(0)
})

Expand Down Expand Up @@ -346,7 +338,7 @@ describe('NewFileMenu getEntries filter', () => {
root: '/files/admin',
})

const entries = newFileMenu.getEntries(context, view)
const entries = newFileMenu.getEntries(context)
expect(entries).toHaveLength(1)
expect(entries[0]).toBe(entry1)
})
Expand Down
3 changes: 2 additions & 1 deletion lib/newFileMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ export interface Entry {
/**
* Function to be run after creation
* @param {Folder} context the creation context. Usually the current folder
* @param {string[]} fileList list of file names present in the destination folder
*/
handler: (context: Folder) => void
handler: (context: Folder, fileList: string[]) => void
}

export class NewFileMenu {
Expand Down