Skip to content

Commit

Permalink
fixup! feat: add sidebar action testing
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Jun 14, 2023
1 parent d997c79 commit 0f6794e
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions apps/files/src/actions/sidebarAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,57 @@
import { action } from './sidebarAction'
import { expect } from '@jest/globals'
import { FileAction } from '../services/FileAction'
import { File } from '@nextcloud/files'

describe('Open sidebar action tests', () => {
test('Default values', () => {
expect(action).toBeInstanceOf(FileAction)
expect(action.id).toBe('details')
expect(action.displayName([], null)).toBe('Details')
expect(action.iconSvgInline([], null)).toBe('SvgMock')
expect(action.default).toBe(true)
expect(action.order).toBe(-50)
})

test('Enabled for ressources within user root folder', () => {
window.OCA = { Files: { Sidebar: {} } }

const file = new File({
id: 1,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
owner: 'admin',
mime: 'text/plain',
})
expect(action.enabled).toBeDefined()
// @ts-ignore we checked if it was defined
expect(action.enabled([file], null)).toBe(true)
})

test('Not enabled if no Sidebar', () => {
window.OCA = {}

const file = new File({
id: 1,
source: 'https://cloud.domain.com/remote.php/dav/files/admin/foobar.txt',
owner: 'admin',
mime: 'text/plain',
})
expect(action.enabled).toBeDefined()
// @ts-ignore we checked if it was defined
expect(action.enabled([file], null)).toBe(false)
})

test('Not enabled for external ressources', () => {
window.OCA = { Files: { Sidebar: {} } }

const file = new File({
id: 1,
source: 'https://domain.com/documents/admin/foobar.txt',
owner: 'admin',
mime: 'text/plain',
})
expect(action.enabled).toBeDefined()
// @ts-ignore we checked if it was defined
expect(action.enabled([file], null)).toBe(false)
})
})

0 comments on commit 0f6794e

Please sign in to comment.