blob: b7002412561ba38876f3e836cb89e8a60bbc1830 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
import { GlDisclosureDropdown } from '@gitlab/ui';
import { shallowMount } from '@vue/test-utils';
import WikiExport from '~/pages/shared/wikis/components/wiki_export.vue';
import printMarkdownDom from '~/lib/print_markdown_dom';
jest.mock('~/lib/print_markdown_dom');
describe('pages/shared/wikis/components/wiki_export', () => {
let wrapper;
const createComponent = (provide) => {
wrapper = shallowMount(WikiExport, {
provide,
});
};
const findDropdown = () => wrapper.findComponent(GlDisclosureDropdown);
const findPrintItem = () =>
findDropdown()
.props('items')
.find((x) => x.text === 'Print as PDF');
describe('print', () => {
beforeEach(() => {
document.body.innerHTML = '<div id="content-body">Content</div>';
});
afterEach(() => {
document.body.innerHTML = '';
});
it('should print the content', () => {
createComponent({
target: '#content-body',
title: 'test title',
stylesheet: [],
});
findPrintItem().action();
expect(printMarkdownDom).toHaveBeenCalledWith({
target: document.querySelector('#content-body'),
title: 'test title',
stylesheet: [],
});
});
});
});
|