blob: 2d69f88064293e1c297a918254d4b0344cae1255 (
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
|
import { mount } from '@vue/test-utils';
import { parseTOC } from '../../../../content/frontend/shared/dom_parse_toc';
import TableOfContentsList from '../../../../content/frontend/default/components/table_of_contents_list.vue';
import { createExampleToc } from '../../shared/toc_helper';
describe('frontend/default/components/table_of_contents_list', () => {
let wrapper;
const createComponent = (props = {}) => {
wrapper = mount(TableOfContentsList, {
propsData: {
...props,
},
});
};
const findItemsData = () => parseTOC(wrapper.element);
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
describe('with items', () => {
let items;
beforeEach(() => {
items = createExampleToc();
createComponent({ items });
});
it('renders all items', () => {
expect(findItemsData()).toEqual(items);
});
});
describe('with empty items', () => {
beforeEach(() => {
createComponent({ items: [] });
});
it('shows empty ul', () => {
expect(wrapper.element).toMatchSnapshot();
});
});
});
|