debian-mirror-gitlab/spec/javascripts/pdf/index_spec.js

62 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2019-09-04 21:01:54 +05:30
import { GlobalWorkerOptions } from 'pdfjs-dist/build/pdf';
import workerSrc from 'pdfjs-dist/build/pdf.worker.min';
2017-08-17 22:00:37 +05:30
import PDFLab from '~/pdf/index.vue';
2019-07-31 22:56:46 +05:30
import { FIXTURES_PATH } from 'spec/test_constants';
const pdf = `${FIXTURES_PATH}/blob/pdf/test.pdf`;
2017-08-17 22:00:37 +05:30
2019-04-03 18:18:56 +05:30
GlobalWorkerOptions.workerSrc = workerSrc;
2017-08-17 22:00:37 +05:30
const Component = Vue.extend(PDFLab);
describe('PDF component', () => {
let vm;
2018-12-13 13:39:08 +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', () => {
2018-12-13 13:39:08 +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', () => {
2018-12-13 13:39:08 +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();
});
});
});