2017-08-17 22:00:37 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
import { FIXTURES_PATH } from 'spec/test_constants';
|
2020-01-01 13:55:28 +05:30
|
|
|
import PDFLab from '~/pdf/index.vue';
|
2019-07-31 22:56:46 +05:30
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
jest.mock('pdfjs-dist/webpack', () => {
|
|
|
|
return { default: jest.requireActual('pdfjs-dist/build/pdf') };
|
|
|
|
});
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
const pdf = `${FIXTURES_PATH}/blob/pdf/test.pdf`;
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
const Component = Vue.extend(PDFLab);
|
|
|
|
|
|
|
|
describe('PDF component', () => {
|
|
|
|
let vm;
|
|
|
|
|
2021-03-08 18:12:59 +05:30
|
|
|
const checkLoaded = (done) => {
|
2017-08-17 22:00:37 +05:30
|
|
|
if (vm.loading) {
|
|
|
|
setTimeout(() => {
|
|
|
|
checkLoaded(done);
|
|
|
|
}, 100);
|
|
|
|
} else {
|
|
|
|
done();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('without PDF data', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
beforeEach((done) => {
|
2017-08-17 22:00:37 +05:30
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
pdf: '',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
vm.$mount();
|
|
|
|
|
|
|
|
checkLoaded(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('does not render', () => {
|
|
|
|
expect(vm.$el.tagName).toBeUndefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe('with PDF data', () => {
|
2021-03-08 18:12:59 +05:30
|
|
|
beforeEach((done) => {
|
2017-08-17 22:00:37 +05:30
|
|
|
vm = new Component({
|
|
|
|
propsData: {
|
|
|
|
pdf,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
vm.$mount();
|
|
|
|
|
|
|
|
checkLoaded(done);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('renders pdf component', () => {
|
|
|
|
expect(vm.$el.tagName).toBeDefined();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|