-
Notifications
You must be signed in to change notification settings - Fork 159
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb441fc
commit a73cfba
Showing
3 changed files
with
5 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 2 additions & 109 deletions
111
packages/web-runtime/tests/unit/pages/resolveFileLink.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | ||
}) | ||
} |