debian-mirror-gitlab/spec/frontend/pdf/page_spec.js

36 lines
872 B
JavaScript
Raw Normal View History

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