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
12 changes: 0 additions & 12 deletions __tests__/jest-setup.ts

This file was deleted.

5 changes: 5 additions & 0 deletions __tests__/mock-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { beforeEach } from 'vitest'

window.OC = { ...window.OC }
window.OCA = { ...window.OCA }
window.OCP = { ...window.OCP }

beforeEach(() => {
window.location = new URL('http://nextcloud.local')
})
5 changes: 5 additions & 0 deletions __tests__/setup-testing-library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: CC0-1.0
*/
import '@testing-library/jest-dom/vitest'
6 changes: 0 additions & 6 deletions __tests__/tsconfig.json

This file was deleted.

17 changes: 9 additions & 8 deletions apps/comments/src/actions/inlineUnreadCommentsAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { action } from './inlineUnreadCommentsAction'
import { expect } from '@jest/globals'
import { File, Permission, View, FileAction } from '@nextcloud/files'
import { describe, expect, test, vi } from 'vitest'

import { action } from './inlineUnreadCommentsAction'
import logger from '../logger'

const view = {
Expand All @@ -29,7 +30,7 @@ describe('Inline unread comments action display name tests', () => {
expect(action.id).toBe('comments-unread')
expect(action.displayName([file], view)).toBe('')
expect(action.title!([file], view)).toBe('1 new comment')
expect(action.iconSvgInline([], view)).toBe('<svg>SvgMock</svg>')
expect(action.iconSvgInline([], view)).toMatch(/<svg.+<\/svg>/)
expect(action.enabled!([file], view)).toBe(true)
expect(action.inline!(file, view)).toBe(true)
expect(action.default).toBeUndefined()
Expand Down Expand Up @@ -115,8 +116,8 @@ describe('Inline unread comments action enabled tests', () => {

describe('Inline unread comments action execute tests', () => {
test('Action opens sidebar', async () => {
const openMock = jest.fn()
const setActiveTabMock = jest.fn()
const openMock = vi.fn()
const setActiveTabMock = vi.fn()
window.OCA = {
Files: {
Sidebar: {
Expand Down Expand Up @@ -145,8 +146,8 @@ describe('Inline unread comments action execute tests', () => {
})

test('Action handles sidebar open failure', async () => {
const openMock = jest.fn(() => { throw new Error('Mock error') })
const setActiveTabMock = jest.fn()
const openMock = vi.fn(() => { throw new Error('Mock error') })
const setActiveTabMock = vi.fn()
window.OCA = {
Files: {
Sidebar: {
Expand All @@ -155,7 +156,7 @@ describe('Inline unread comments action execute tests', () => {
},
},
}
jest.spyOn(logger, 'error').mockImplementation(() => jest.fn())
vi.spyOn(logger, 'error').mockImplementation(() => vi.fn())

const file = new File({
id: 1,
Expand Down
27 changes: 10 additions & 17 deletions apps/dav/src/views/CalDavSettings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,33 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { render } from '@testing-library/vue'
import { beforeEach, describe, expect, test, vi } from 'vitest'

import CalDavSettings from './CalDavSettings.vue'
// eslint-disable-next-line no-unused-vars
import { generateUrl } from '@nextcloud/router'

jest.mock('@nextcloud/axios')
jest.mock('@nextcloud/router', () => {
vi.mock('@nextcloud/axios')
vi.mock('@nextcloud/router', () => {
return {
generateUrl(url) {
return url
},
}
})
jest.mock('@nextcloud/initial-state', () => {
vi.mock('@nextcloud/initial-state', () => {
return {
loadState: jest.fn(() => 'https://docs.nextcloud.com/server/23/go.php?to=user-sync-calendars'),
loadState: vi.fn(() => 'https://docs.nextcloud.com/server/23/go.php?to=user-sync-calendars'),
}
})

describe('CalDavSettings', () => {
const originalOC = global.OC
const originalOCP = global.OCP

beforeEach(() => {
global.OC = { requestToken: 'secret' }
global.OCP = {
window.OC = { requestToken: 'secret' }
window.OCP = {
AppConfig: {
setValue: jest.fn(),
setValue: vi.fn(),
},
}
})
afterAll(() => {
global.OC = originalOC
global.OCP = originalOCP
})

test('interactions', async () => {
const TLUtils = render(
Expand All @@ -53,7 +46,7 @@ describe('CalDavSettings', () => {
},
},
Vue => {
Vue.prototype.$t = jest.fn((app, text) => text)
Vue.prototype.$t = vi.fn((app, text) => text)
},
)
expect(TLUtils.container).toMatchSnapshot()
Expand Down
Loading