Commit eb578529 authored by Jacques's avatar Jacques Committed by Jacques Erasmus

Use PDF Viewer when vewing a PDF blob

Created a PDF blob viewer
parent bef5540c
...@@ -12,6 +12,8 @@ export const loadViewer = (type) => { ...@@ -12,6 +12,8 @@ export const loadViewer = (type) => {
return () => import(/* webpackChunkName: 'blob_image_viewer' */ './image_viewer.vue'); return () => import(/* webpackChunkName: 'blob_image_viewer' */ './image_viewer.vue');
case 'video': case 'video':
return () => import(/* webpackChunkName: 'blob_video_viewer' */ './video_viewer.vue'); return () => import(/* webpackChunkName: 'blob_video_viewer' */ './video_viewer.vue');
case 'pdf':
return () => import(/* webpackChunkName: 'blob_pdf_viewer' */ './pdf_viewer.vue');
default: default:
return null; return null;
} }
...@@ -36,5 +38,8 @@ export const viewerProps = (type, blob) => { ...@@ -36,5 +38,8 @@ export const viewerProps = (type, blob) => {
video: { video: {
url: blob.rawPath, url: blob.rawPath,
}, },
pdf: {
url: blob.rawPath,
},
}[type]; }[type];
}; };
<script>
import PdfViewer from '~/blob/pdf/pdf_viewer.vue';
export default {
components: { PdfViewer },
props: {
url: {
type: String,
required: true,
},
},
};
</script>
<template>
<pdf-viewer :pdf="url" />
</template>
import { shallowMount } from '@vue/test-utils';
import Component from '~/repository/components/blob_viewers/pdf_viewer.vue';
import PdfViewer from '~/blob/pdf/pdf_viewer.vue';
describe('PDF Viewer', () => {
let wrapper;
const propsData = { url: 'some/pdf_blob.pdf' };
const createComponent = () => {
wrapper = shallowMount(Component, { propsData });
};
const findPDFViewer = () => wrapper.findComponent(PdfViewer);
it('renders a PDF Viewer component', () => {
createComponent();
expect(findPDFViewer().exists()).toBe(true);
expect(findPDFViewer().props('pdf')).toBe(propsData.url);
});
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment