|
|
|
@ -24,6 +24,11 @@ import { expect } from '@jest/globals'
|
|
|
|
|
import { File, Folder, Node, Permission, View, FileAction } from '@nextcloud/files'
|
|
|
|
|
|
|
|
|
|
const view = {
|
|
|
|
|
id: 'trashbin',
|
|
|
|
|
name: 'Trashbin',
|
|
|
|
|
} as View
|
|
|
|
|
|
|
|
|
|
const viewFiles = {
|
|
|
|
|
id: 'files',
|
|
|
|
|
name: 'Files',
|
|
|
|
|
} as View
|
|
|
|
@ -36,11 +41,12 @@ describe('View in folder action conditions tests', () => {
|
|
|
|
|
expect(action.iconSvgInline([], view)).toBe('<svg>SvgMock</svg>')
|
|
|
|
|
expect(action.default).toBeUndefined()
|
|
|
|
|
expect(action.order).toBe(80)
|
|
|
|
|
expect(action.enabled).toBeDefined()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('View in folder action enabled tests', () => {
|
|
|
|
|
test('Enabled for files', () => {
|
|
|
|
|
test('Enabled for trashbin', () => {
|
|
|
|
|
const file = new File({
|
|
|
|
|
id: 1,
|
|
|
|
|
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
|
|
|
|
@ -53,6 +59,19 @@ describe('View in folder action enabled tests', () => {
|
|
|
|
|
expect(action.enabled!([file], view)).toBe(true)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('Disabled for files', () => {
|
|
|
|
|
const file = new File({
|
|
|
|
|
id: 1,
|
|
|
|
|
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
|
|
|
|
|
owner: 'admin',
|
|
|
|
|
mime: 'text/plain',
|
|
|
|
|
permissions: Permission.ALL,
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
expect(action.enabled).toBeDefined()
|
|
|
|
|
expect(action.enabled!([file], viewFiles)).toBe(false)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
test('Disabled without permissions', () => {
|
|
|
|
|
const file = new File({
|
|
|
|
|
id: 1,
|
|
|
|
|