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

60 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
import Vue from 'vue';
2019-04-03 18:18:56 +05:30
import { GlobalWorkerOptions } from 'vendor/pdf';
2017-09-10 17:25:29 +05:30
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';
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();
});
});
});