summaryrefslogtreecommitdiffstats
path: root/apps/files/src/actions/deleteAction.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/src/actions/deleteAction.spec.ts')
-rw-r--r--apps/files/src/actions/deleteAction.spec.ts81
1 files changed, 63 insertions, 18 deletions
diff --git a/apps/files/src/actions/deleteAction.spec.ts b/apps/files/src/actions/deleteAction.spec.ts
index c568ec59d9d..0adb302dc32 100644
--- a/apps/files/src/actions/deleteAction.spec.ts
+++ b/apps/files/src/actions/deleteAction.spec.ts
@@ -22,9 +22,9 @@
import { action } from './deleteAction'
import { expect } from '@jest/globals'
import { File, Folder, Permission, View, FileAction } from '@nextcloud/files'
-import * as auth from '@nextcloud/auth'
import * as eventBus from '@nextcloud/event-bus'
import axios from '@nextcloud/axios'
+
import logger from '../logger'
const view = {
@@ -50,36 +50,81 @@ describe('Delete action conditions tests', () => {
permissions: Permission.ALL,
})
- // const file2 = new File({
- // id: 1,
- // source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
- // owner: 'admin',
- // mime: 'text/plain',
- // permissions: Permission.ALL,
- // })
+ const file2 = new File({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
+ owner: 'admin',
+ mime: 'text/plain',
+ permissions: Permission.ALL,
+ attributes: {
+ 'is-mount-root': true,
+ 'mount-type': 'shared',
+ },
+ })
+
+ const folder = new Folder({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/Foo',
+ owner: 'admin',
+ mime: 'text/plain',
+ permissions: Permission.ALL,
+ })
+
+ const folder2 = new Folder({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/Foo',
+ owner: 'admin',
+ mime: 'text/plain',
+ permissions: Permission.ALL,
+ attributes: {
+ 'is-mount-root': true,
+ 'mount-type': 'shared',
+ },
+ })
+
+ const folder3 = new Folder({
+ id: 1,
+ source: 'https://cloud.domain.com/remote.php/dav/files/admin/Foo',
+ owner: 'admin',
+ mime: 'text/plain',
+ permissions: Permission.ALL,
+ attributes: {
+ 'is-mount-root': true,
+ 'mount-type': 'external',
+ },
+ })
test('Default values', () => {
expect(action).toBeInstanceOf(FileAction)
expect(action.id).toBe('delete')
- expect(action.displayName([file], view)).toBe('Delete')
+ expect(action.displayName([file], view)).toBe('Delete file')
expect(action.iconSvgInline([], view)).toBe('<svg>SvgMock</svg>')
expect(action.default).toBeUndefined()
expect(action.order).toBe(100)
})
- test('Default trashbin view values', () => {
+ test('Default folder displayName', () => {
+ expect(action.displayName([folder], view)).toBe('Delete folder')
+ })
+
+ test('Default trashbin view displayName', () => {
expect(action.displayName([file], trashbinView)).toBe('Delete permanently')
})
- // TODO: Fix this test
- // test('Shared node values', () => {
- // jest.spyOn(auth, 'getCurrentUser').mockReturnValue(null)
- // expect(action.displayName([file2], view)).toBe('Unshare')
- // })
+ test('Shared root node displayName', () => {
+ expect(action.displayName([file2], view)).toBe('Leave this share')
+ expect(action.displayName([folder2], view)).toBe('Leave this share')
+ expect(action.displayName([file2, folder2], view)).toBe('Leave these shares')
+ })
+
+ test('External storage root node displayName', () => {
+ expect(action.displayName([folder3], view)).toBe('Disconnect storage')
+ expect(action.displayName([folder3, folder3], view)).toBe('Disconnect storages')
+ })
- // test('Shared and owned nodes values', () => {
- // expect(action.displayName([file, file2], view)).toBe('Delete and unshare')
- // })
+ test('Shared and owned nodes displayName', () => {
+ expect(action.displayName([file, file2], view)).toBe('Delete and unshare')
+ })
})
describe('Delete action enabled tests', () => {