aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/actions/renameAction.spec.ts
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files/src/actions/renameAction.spec.ts')
-rw-r--r--apps/files/src/actions/renameAction.spec.ts51
1 files changed, 21 insertions, 30 deletions
diff --git a/apps/files/src/actions/renameAction.spec.ts b/apps/files/src/actions/renameAction.spec.ts
index 7166483f72c..1f9c9209d41 100644
--- a/apps/files/src/actions/renameAction.spec.ts
+++ b/apps/files/src/actions/renameAction.spec.ts
@@ -1,40 +1,31 @@
/**
- * @copyright Copyright (c) 2023 John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- *
- * @license AGPL-3.0-or-later
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { action } from './renameAction'
-import { expect } from '@jest/globals'
-import { File, Permission, View, FileAction } from '@nextcloud/files'
+import { File, Folder, Permission, View, FileAction } from '@nextcloud/files'
import * as eventBus from '@nextcloud/event-bus'
+import { describe, expect, test, vi, beforeEach } from 'vitest'
+import { useFilesStore } from '../store/files'
+import { getPinia } from '../store/index.ts'
const view = {
id: 'files',
name: 'Files',
} as View
+beforeEach(() => {
+ const root = new Folder({ owner: 'test', source: 'https://cloud.domain.com/remote.php/dav/files/admin/', id: 1, permissions: Permission.CREATE })
+ const files = useFilesStore(getPinia())
+ files.setRoot({ service: 'files', root })
+})
+
describe('Rename action conditions tests', () => {
test('Default values', () => {
expect(action).toBeInstanceOf(FileAction)
expect(action.id).toBe('rename')
expect(action.displayName([], view)).toBe('Rename')
- expect(action.iconSvgInline([], view)).toBe('<svg>SvgMock</svg>')
+ expect(action.iconSvgInline([], view)).toMatch(/<svg.+<\/svg>/)
expect(action.default).toBeUndefined()
expect(action.order).toBe(10)
})
@@ -43,20 +34,20 @@ describe('Rename action conditions tests', () => {
describe('Rename action enabled tests', () => {
test('Enabled for node with UPDATE permission', () => {
const file = new File({
- id: 1,
+ id: 2,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
owner: 'admin',
mime: 'text/plain',
- permissions: Permission.UPDATE,
+ permissions: Permission.UPDATE | Permission.DELETE,
})
expect(action.enabled).toBeDefined()
expect(action.enabled!([file], view)).toBe(true)
})
- test('Disabled for node without UPDATE permission', () => {
+ test('Disabled for node without DELETE permission', () => {
const file = new File({
- id: 1,
+ id: 2,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
owner: 'admin',
mime: 'text/plain',
@@ -71,13 +62,13 @@ describe('Rename action enabled tests', () => {
window.OCA = { Files: { Sidebar: {} } }
const file1 = new File({
- id: 1,
+ id: 2,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foo.txt',
owner: 'admin',
mime: 'text/plain',
})
const file2 = new File({
- id: 1,
+ id: 2,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/bar.txt',
owner: 'admin',
mime: 'text/plain',
@@ -90,10 +81,10 @@ describe('Rename action enabled tests', () => {
describe('Rename action exec tests', () => {
test('Rename', async () => {
- jest.spyOn(eventBus, 'emit')
+ vi.spyOn(eventBus, 'emit')
const file = new File({
- id: 1,
+ id: 2,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
owner: 'admin',
mime: 'text/plain',