2017-08-17 22:00:37 +05:30
|
|
|
/* eslint-disable import/no-unresolved */
|
|
|
|
|
|
|
|
import Vue from 'vue';
|
2017-09-10 17:25:29 +05:30
|
|
|
import { PDFJS } from 'vendor/pdf';
|
|
|
|
import workerSrc from 'vendor/pdf.worker.min';
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
import PDFLab from '~/pdf/index.vue';
|
|
|
|
import pdf from '../fixtures/blob/pdf/test.pdf';
|
|
|
|
|
|
|
|
PDFJS.workerSrc = workerSrc;
|
|
|
|
const Component = Vue.extend(PDFLab);
|
|
|
|
|
|
|
|
describe('PDF component', () => {
|
|
|
|
let vm;
|
|
|
|
|
|
|
|
const checkLoaded = (done) => {
|
|
|
|
if (vm.loading) {
|
|
|
|
setTimeout(() => {
|
|
|
|
checkLoaded(done);
|
|
|
|
}, 100);
|
|
|
|
} else {
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('without PDF data', () => {
|
|
|
|
beforeEach((done) => {
|
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
pdf: '',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
vm.$mount();
|
|
|
|
|
|
|
|
checkLoaded(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render', () => {
|
|
|
|
expect(vm.$el.tagName).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with PDF data', () => {
|
|
|
|
beforeEach((done) => {
|
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
pdf,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
vm.$mount();
|
|
|
|
|
|
|
|
checkLoaded(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders pdf component', () => {
|
|
|
|
expect(vm.$el.tagName).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|