2022-11-25 23:54:43 +05:30
|
|
|
import { nextTick } from 'vue';
|
|
|
|
import { mount } from '@vue/test-utils';
|
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', () => {
|
2022-11-25 23:54:43 +05:30
|
|
|
return { default: jest.requireActual('pdfjs-dist/legacy/build/pdf') };
|
2020-06-23 00:09:42 +05:30
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
|
|
|
|
describe('Page component', () => {
|
2022-11-25 23:54:43 +05:30
|
|
|
let wrapper;
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
afterEach(() => {
|
2022-11-25 23:54:43 +05:30
|
|
|
wrapper.destroy();
|
2018-11-20 20:47:30 +05:30
|
|
|
});
|
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
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
wrapper = mount(PageComponent, {
|
|
|
|
propsData: {
|
|
|
|
page: testPage,
|
|
|
|
number: 1,
|
|
|
|
},
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
2018-12-13 13:39:08 +05:30
|
|
|
|
2022-06-21 17:19:12 +05:30
|
|
|
await nextTick();
|
|
|
|
|
2022-11-25 23:54:43 +05:30
|
|
|
expect(testPage.render).toHaveBeenCalledWith({
|
|
|
|
canvasContext: wrapper.find('canvas').element.getContext('2d'),
|
|
|
|
viewport: testPage.getViewport(),
|
|
|
|
});
|
2017-08-17 22:00:37 +05:30
|
|
|
});
|
|
|
|
});
|