blob: b6c8c467028c3c3c064416c00f23c39168d1a975 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
|
import { mount } from '@vue/test-utils';
import orderedLayout from '~/vue_shared/components/ordered_layout.vue';
const children = `
<template v-slot:header>
<header></header>
</template>
<template v-slot:footer>
<footer></footer>
</template>
`;
const TestComponent = {
components: { orderedLayout },
template: `
<div>
<ordered-layout v-bind="$attrs">
${children}
</ordered-layout>
</div>
`,
};
const regularSlotOrder = ['header', 'footer'];
describe('Ordered Layout', () => {
let wrapper;
const verifyOrder = () =>
wrapper
.findAll('footer,header')
.wrappers.map((x) => (x.element.tagName === 'FOOTER' ? 'footer' : 'header'));
const createComponent = (props = {}) => {
wrapper = mount(TestComponent, {
propsData: props,
});
};
describe('when slotKeys are in initial slot order', () => {
beforeEach(() => {
createComponent({ slotKeys: regularSlotOrder });
});
it('confirms order of the component is reflective of slotKeys', () => {
expect(verifyOrder()).toEqual(regularSlotOrder);
});
});
describe('when slotKeys reverse the order of the props', () => {
const reversedSlotOrder = regularSlotOrder.reverse();
beforeEach(() => {
createComponent({ slotKeys: reversedSlotOrder });
});
it('confirms order of the component is reflective of slotKeys', () => {
expect(verifyOrder()).toEqual(reversedSlotOrder);
});
});
});
|