From a73cfba9fb0ebce1560bafa2959bf6f72a2c398b Mon Sep 17 00:00:00 2001 From: Jannik Stehle Date: Tue, 11 Oct 2022 08:39:14 +0200 Subject: [PATCH] Fix unit tests --- .../SideBar/Shares/FileLinks.spec.js | 4 +- .../Shares/Links/DetailsAndEdit.spec.js | 2 +- .../tests/unit/pages/resolveFileLink.spec.ts | 111 +----------------- 3 files changed, 5 insertions(+), 112 deletions(-) diff --git a/packages/web-app-files/tests/unit/components/SideBar/Shares/FileLinks.spec.js b/packages/web-app-files/tests/unit/components/SideBar/Shares/FileLinks.spec.js index ba92293c83b..97b1a716675 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/Shares/FileLinks.spec.js +++ b/packages/web-app-files/tests/unit/components/SideBar/Shares/FileLinks.spec.js @@ -31,7 +31,7 @@ const defaultLinksList = [ name: 'public link 1', url: 'some-link-1', path: '/file-1.txt', - permissions: '1' + permissions: 1 }, { id: '2', @@ -39,7 +39,7 @@ const defaultLinksList = [ name: 'public link 2', url: 'some-link-2', path: '/file-2.txt', - permissions: '1' + permissions: 1 } ] diff --git a/packages/web-app-files/tests/unit/components/SideBar/Shares/Links/DetailsAndEdit.spec.js b/packages/web-app-files/tests/unit/components/SideBar/Shares/Links/DetailsAndEdit.spec.js index e168d97aeff..f6e224574a8 100644 --- a/packages/web-app-files/tests/unit/components/SideBar/Shares/Links/DetailsAndEdit.spec.js +++ b/packages/web-app-files/tests/unit/components/SideBar/Shares/Links/DetailsAndEdit.spec.js @@ -19,7 +19,7 @@ const availableRoleOptions = LinkShareRoles.list(false, true, true) const exampleLink = { name: 'Example link', url: 'https://some-url.com/abc', - permissions: '1' + permissions: 1 } describe('DetailsAndEdit component', () => { diff --git a/packages/web-runtime/tests/unit/pages/resolveFileLink.spec.ts b/packages/web-runtime/tests/unit/pages/resolveFileLink.spec.ts index 0e53f17881e..560deae782c 100644 --- a/packages/web-runtime/tests/unit/pages/resolveFileLink.spec.ts +++ b/packages/web-runtime/tests/unit/pages/resolveFileLink.spec.ts @@ -1,110 +1,3 @@ -import { shallowMount } from '@vue/test-utils' -import { getRouter, getStore, localVue } from './views.setup' -import resolveFileLink from '../../../src/pages/resolveFileLink.vue' -import fileFixtures from '../../../../../__fixtures__/files' - -localVue.prototype.$client.files = { - getPathForFileId: jest.fn(() => Promise.resolve('/lorem.txt')) -} - -const theme = { - general: { slogan: 'some-slogan' } -} - -const $route = { - params: { - fileId: '2147491323' - }, - meta: { - title: 'Resolving private link' - } -} - -const selectors = { - pageTitle: 'h1.oc-invisible-sr', - loader: '.oc-card-body', - errorTitle: '.oc-link-resolve-error-title' -} - -describe('PrivateLink view', () => { - it.todo('adapt tests, see comment in Favorites.spec.ts...') - // afterEach(() => { - // jest.clearAllMocks() - // }) - // - // describe('when the page has loaded successfully', () => { - // let wrapper - // beforeEach(() => { - // wrapper = getShallowWrapper() - // }) - // - // it('should display the page title', () => { - // expect(wrapper.find(selectors.pageTitle)).toMatchSnapshot() - // }) - // it('should resolve the provided file id to a path', () => { - // expect(wrapper.vm.$client.files.getPathForFileId).toHaveBeenCalledTimes(1) - // }) - // }) - // - // describe('when the view is still loading', () => { - // it('should display the loading text with the spinner', () => { - // const wrapper = getShallowWrapper(true) - // - // expect(wrapper.find(selectors.loader)).toMatchSnapshot() - // }) - // }) - // - // describe('when there was an error', () => { - // it('should display the error message', async () => { - // jest.spyOn(console, 'error').mockImplementation(() => {}) - // const wrapper = getShallowWrapper( - // false, - // jest.fn(() => Promise.reject(Error('some error'))) - // ) - // - // await new Promise((resolve) => { - // setTimeout(() => { - // expect(wrapper.find(selectors.errorTitle)).toMatchSnapshot() - // resolve() - // }, 1) - // }) - // }) - // }) - // - // describe('when the view has finished loading and there was no error', () => { - // it('should not display the loading text and the error message', () => { - // const wrapper = getShallowWrapper() - // - // expect(wrapper).toMatchSnapshot() - // }) - // }) +describe('resolveFileLink view', () => { + it.todo('Write tests') }) - -function getShallowWrapper(loading = false, getPathForFileIdMock = jest.fn()) { - return shallowMount(resolveFileLink, { - localVue, - store: createStore(), - mocks: { - $route, - $router: getRouter({}), - $client: { - files: { - fileInfo: jest.fn().mockImplementation(() => Promise.resolve(fileFixtures['/'][4])), - getPathForFileId: getPathForFileIdMock - } - } - }, - data() { - return { - loading - } - } - }) -} - -function createStore() { - return getStore({ - slogan: theme.general.slogan, - user: { id: 1 } - }) -}