2017-04-12 02:44:22 +00:00
|
|
|
import Vue from 'vue';
|
2019-05-06 23:37:13 +00:00
|
|
|
import { GlobalWorkerOptions } from 'pdfjs-dist/build/pdf';
|
|
|
|
import workerSrc from 'pdfjs-dist/build/pdf.worker.min';
|
2017-04-12 02:44:22 +00:00
|
|
|
|
|
|
|
import PDFLab from '~/pdf/index.vue';
|
2019-04-25 12:22:00 +00:00
|
|
|
import { FIXTURES_PATH } from 'spec/test_constants';
|
|
|
|
|
|
|
|
const pdf = `${FIXTURES_PATH}/blob/pdf/test.pdf`;
|
2017-04-12 02:44:22 +00:00
|
|
|
|
2019-03-13 12:59:15 +00:00
|
|
|
GlobalWorkerOptions.workerSrc = workerSrc;
|
2017-04-12 02:44:22 +00:00
|
|
|
const Component = Vue.extend(PDFLab);
|
|
|
|
|
|
|
|
describe('PDF component', () => {
|
|
|
|
let vm;
|
|
|
|
|
2018-10-17 07:13:26 +00:00
|
|
|
const checkLoaded = done => {
|
2017-04-12 02:44:22 +00:00
|
|
|
if (vm.loading) {
|
|
|
|
setTimeout(() => {
|
|
|
|
checkLoaded(done);
|
|
|
|
}, 100);
|
|
|
|
} else {
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('without PDF data', () => {
|
2018-10-17 07:13:26 +00:00
|
|
|
beforeEach(done => {
|
2017-04-12 02:44:22 +00:00
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
pdf: '',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
vm.$mount();
|
|
|
|
|
|
|
|
checkLoaded(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render', () => {
|
|
|
|
expect(vm.$el.tagName).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with PDF data', () => {
|
2018-10-17 07:13:26 +00:00
|
|
|
beforeEach(done => {
|
2017-04-12 02:44:22 +00:00
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
pdf,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
vm.$mount();
|
|
|
|
|
|
|
|
checkLoaded(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders pdf component', () => {
|
|
|
|
expect(vm.$el.tagName).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|