2022-04-13 17:09:57 -04:00
|
|
|
import Vue, { nextTick } from 'vue';
|
2020-06-15 08:08:44 -04:00
|
|
|
import mountComponent from 'helpers/vue_mount_component_helper';
|
2020-08-17 17:09:56 -04:00
|
|
|
import PageComponent from '~/pdf/page/index.vue';
|
2019-04-25 08:22:00 -04:00
|
|
|
|
2020-06-15 08:08:44 -04:00
|
|
|
jest.mock('pdfjs-dist/webpack', () => {
|
|
|
|
return { default: jest.requireActual('pdfjs-dist/build/pdf') };
|
|
|
|
});
|
2017-04-11 22:44:22 -04:00
|
|
|
|
|
|
|
describe('Page component', () => {
|
2018-08-23 15:05:20 -04:00
|
|
|
const Component = Vue.extend(PageComponent);
|
2017-04-11 22:44:22 -04:00
|
|
|
let vm;
|
|
|
|
|
2018-08-23 15:05:20 -04:00
|
|
|
afterEach(() => {
|
|
|
|
vm.$destroy();
|
|
|
|
});
|
2017-04-11 22:44:22 -04:00
|
|
|
|
2022-04-13 17:09:57 -04:00
|
|
|
it('renders the page when mounting', async () => {
|
2020-06-15 08:08:44 -04:00
|
|
|
const testPage = {
|
|
|
|
render: jest.fn().mockReturnValue({ promise: Promise.resolve() }),
|
|
|
|
getViewport: jest.fn().mockReturnValue({}),
|
|
|
|
};
|
2019-07-29 15:47:40 -04:00
|
|
|
|
2018-08-23 15:05:20 -04:00
|
|
|
vm = mountComponent(Component, {
|
|
|
|
page: testPage,
|
|
|
|
number: 1,
|
2017-04-11 22:44:22 -04:00
|
|
|
});
|
2018-10-09 14:03:09 -04:00
|
|
|
|
2018-08-23 15:05:20 -04:00
|
|
|
expect(vm.rendering).toBe(true);
|
2017-04-11 22:44:22 -04:00
|
|
|
|
2022-04-13 17:09:57 -04:00
|
|
|
await nextTick();
|
|
|
|
|
|
|
|
expect(testPage.render).toHaveBeenCalledWith(vm.renderContext);
|
|
|
|
expect(vm.rendering).toBe(false);
|
2017-04-11 22:44:22 -04:00
|
|
|
});
|
|
|
|
});
|