diff --git a/apps/files/src/composables/useFileListHeaders.spec.ts b/apps/files/src/composables/useFileListHeaders.spec.ts index 32f0422b66f..8e496713cbe 100644 --- a/apps/files/src/composables/useFileListHeaders.spec.ts +++ b/apps/files/src/composables/useFileListHeaders.spec.ts @@ -5,8 +5,7 @@ import { beforeEach, describe, expect, it, jest } from '@jest/globals' import { useFileListHeaders } from './useFileListHeaders.ts' -import { Header } from '@nextcloud/files' -import * as ncFiles from '@nextcloud/files' +import { Header, getFileListHeaders } from '@nextcloud/files' jest.mock('@nextcloud/files', () => ({ ...jest.requireActual('@nextcloud/files'), @@ -21,22 +20,22 @@ describe('useFileListHeaders', () => { it('gets the headers', () => { const header = new Header({ id: '1', order: 5, render: jest.fn(), updated: jest.fn() }) // @ts-expect-error its mocked - ncFiles.getFileListHeaders.mockImplementationOnce(() => [header]) + getFileListHeaders.mockImplementationOnce(() => [header]) const headers = useFileListHeaders() expect(headers.value).toEqual([header]) - expect(ncFiles.getFileListHeaders).toBeCalled() + expect(getFileListHeaders).toBeCalled() }) it('headers are sorted', () => { const header = new Header({ id: '1', order: 10, render: jest.fn(), updated: jest.fn() }) const header2 = new Header({ id: '2', order: 5, render: jest.fn(), updated: jest.fn() }) // @ts-expect-error its mocked - ncFiles.getFileListHeaders.mockImplementationOnce(() => [header, header2]) + getFileListHeaders.mockImplementationOnce(() => [header, header2]) const headers = useFileListHeaders() // lower order first expect(headers.value.map(({ id }) => id)).toStrictEqual(['2', '1']) - expect(ncFiles.getFileListHeaders).toBeCalled() + expect(getFileListHeaders).toBeCalled() }) }) diff --git a/apps/files/src/composables/useNavigation.spec.ts b/apps/files/src/composables/useNavigation.spec.ts index 364c9ab653d..c3bec078c72 100644 --- a/apps/files/src/composables/useNavigation.spec.ts +++ b/apps/files/src/composables/useNavigation.spec.ts @@ -3,11 +3,16 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ import { beforeEach, describe, expect, it, jest } from '@jest/globals' -import nextcloudFiles, { Navigation, View } from '@nextcloud/files' +import { Navigation, View, getNavigation } from '@nextcloud/files' import { mount } from '@vue/test-utils' import { defineComponent } from 'vue' import { useNavigation } from './useNavigation' +jest.mock('@nextcloud/files', () => ({ + ...jest.requireActual('@nextcloud/files'), + getNavigation: jest.fn(), +})) + // Just a wrapper so we can test the composable const TestComponent = defineComponent({ template: '
', @@ -21,13 +26,13 @@ const TestComponent = defineComponent({ }) describe('Composables: useNavigation', () => { - const spy = jest.spyOn(nextcloudFiles, 'getNavigation') let navigation: Navigation describe('currentView', () => { beforeEach(() => { navigation = new Navigation() - spy.mockImplementation(() => navigation) + // @ts-expect-error its mocked + getNavigation.mockImplementationOnce(() => navigation) }) it('should return null without active navigation', () => { @@ -61,7 +66,8 @@ describe('Composables: useNavigation', () => { describe('views', () => { beforeEach(() => { navigation = new Navigation() - spy.mockImplementation(() => navigation) + // @ts-expect-error its mocked + getNavigation.mockImplementationOnce(() => navigation) }) it('should return empty array without registered views', () => { diff --git a/apps/files/src/views/favorites.spec.ts b/apps/files/src/views/favorites.spec.ts index decf4f1d2c7..edb60ae3af9 100644 --- a/apps/files/src/views/favorites.spec.ts +++ b/apps/files/src/views/favorites.spec.ts @@ -9,7 +9,7 @@ import type { Folder as CFolder, Navigation } from '@nextcloud/files' import { expect } from '@jest/globals' import * as eventBus from '@nextcloud/event-bus' -import * as filesUtils from '@nextcloud/files' +import { Folder, getNavigation } from '@nextcloud/files' import * as filesDavUtils from '@nextcloud/files/dav' import { basename } from 'path' import { CancelablePromise } from 'cancelable-promise' @@ -18,8 +18,6 @@ import { action } from '../actions/favoriteAction' import { registerFavoritesView } from './favorites' import * as favoritesService from '../services/Favorites' -const { Folder, getNavigation } = filesUtils - jest.mock('@nextcloud/axios', () => ({ post: jest.fn(), }))