gitlab-org--gitlab-foss/spec/frontend/pdf/index_spec.js

63 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-04-11 22:44:22 -04:00
import Vue from 'vue';
2019-04-25 08:22:00 -04:00
import { FIXTURES_PATH } from 'spec/test_constants';
import PDFLab from '~/pdf/index.vue';
2019-04-25 08:22:00 -04:00
jest.mock('pdfjs-dist/webpack', () => {
return { default: jest.requireActual('pdfjs-dist/build/pdf') };
});
2019-04-25 08:22:00 -04:00
const pdf = `${FIXTURES_PATH}/blob/pdf/test.pdf`;
2017-04-11 22:44:22 -04:00
const Component = Vue.extend(PDFLab);
describe('PDF component', () => {
let vm;
const checkLoaded = (done) => {
2017-04-11 22:44:22 -04:00
if (vm.loading) {
setTimeout(() => {
checkLoaded(done);
}, 100);
} else {
done();
}
};
describe('without PDF data', () => {
beforeEach((done) => {
2017-04-11 22:44:22 -04:00
vm = new Component({
propsData: {
pdf: '',
},
});
vm.$mount();
checkLoaded(done);
});
it('does not render', () => {
expect(vm.$el.tagName).toBeUndefined();
});
});
describe('with PDF data', () => {
beforeEach((done) => {
2017-04-11 22:44:22 -04:00
vm = new Component({
propsData: {
pdf,
},
});
vm.$mount();
checkLoaded(done);
});
it('renders pdf component', () => {
expect(vm.$el.tagName).toBeDefined();
});
});
});