diff options
Diffstat (limited to 'spec/frontend/pdf')
-rw-r--r-- | spec/frontend/pdf/index_spec.js | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/spec/frontend/pdf/index_spec.js b/spec/frontend/pdf/index_spec.js index 2b0932493bb..98946412264 100644 --- a/spec/frontend/pdf/index_spec.js +++ b/spec/frontend/pdf/index_spec.js @@ -1,48 +1,33 @@ -import Vue from 'vue'; - +import { shallowMount } from '@vue/test-utils'; import { FIXTURES_PATH } from 'spec/test_constants'; import PDFLab from '~/pdf/index.vue'; -jest.mock('pdfjs-dist/webpack', () => { - return { default: jest.requireActual('pdfjs-dist/build/pdf') }; -}); - -const pdf = `${FIXTURES_PATH}/blob/pdf/test.pdf`; +describe('PDFLab component', () => { + let wrapper; -const Component = Vue.extend(PDFLab); + const mountComponent = ({ pdf }) => shallowMount(PDFLab, { propsData: { pdf } }); -describe('PDF component', () => { - let vm; + afterEach(() => { + wrapper.destroy(); + }); describe('without PDF data', () => { beforeEach(() => { - vm = new Component({ - propsData: { - pdf: '', - }, - }); - - vm.$mount(); + wrapper = mountComponent({ pdf: '' }); }); it('does not render', () => { - expect(vm.$el.tagName).toBeUndefined(); + expect(wrapper.isVisible()).toBe(false); }); }); describe('with PDF data', () => { beforeEach(() => { - vm = new Component({ - propsData: { - pdf, - }, - }); - - vm.$mount(); + wrapper = mountComponent({ pdf: `${FIXTURES_PATH}/blob/pdf/test.pdf` }); }); - it('renders pdf component', () => { - expect(vm.$el.tagName).toBeDefined(); + it('renders', () => { + expect(wrapper.isVisible()).toBe(true); }); }); }); |