Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Oct 11, 2022
1 parent fb441fc commit a73cfba
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ const defaultLinksList = [
name: 'public link 1',
url: 'some-link-1',
path: '/file-1.txt',
permissions: '1'
permissions: 1
},
{
id: '2',
indirect: true,
name: 'public link 2',
url: 'some-link-2',
path: '/file-2.txt',
permissions: '1'
permissions: 1
}
]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
111 changes: 2 additions & 109 deletions packages/web-runtime/tests/unit/pages/resolveFileLink.spec.ts
Original file line number Diff line number Diff line change
@@ -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 }
})
}

0 comments on commit a73cfba

Please sign in to comment.