Passed
Push — 6.4 ( cf160f...15d5b2 )
by Christian
22:08 queued 11s
created

sw-cms-visibility-toggle.spec.ts ➔ createWrapper   A

Complexity

Conditions 1

Size

Total Lines 22
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 16
dl 0
loc 22
rs 9.6
c 0
b 0
f 0
1
import { shallowMount, createLocalVue } from '@vue/test-utils';
2
import 'src/module/sw-cms/component/sw-cms-visibility-toggle';
3
import 'src/app/component/base/sw-icon';
4
5
/**
6
 * @package content
7
 */
8
9
async function createWrapper() {
10
    const localVue = createLocalVue();
11
12
    return shallowMount(await Shopware.Component.build('sw-cms-visibility-toggle'), {
13
        localVue,
14
        propsData: {
15
            text: 'Toggle Text Button',
16
            isCollapsed: true,
17
        },
18
        provide: {
19
            cmsService: {}
20
        },
21
        stubs: {
22
            'sw-icon': await Shopware.Component.build('sw-icon'),
23
            'icons-regular-eye-slash': true,
24
            'icons-regular-chevron-down-xs': true,
25
            'icons-regular-chevron-up-xs': true,
26
        },
27
    });
28
}
29
30
describe('module/sw-cms/component/sw-cms-visibility-toggle', () => {
31
    it('should be a Vue.js component', async () => {
32
        const wrapper = await createWrapper();
33
34
        expect(wrapper.vm).toBeTruthy();
35
    });
36
37
    it('should be collapsed', async () => {
38
        const wrapper = await createWrapper();
39
        const toggleButton = wrapper.find('.sw-cms-visibility-toggle__button');
40
        const collapsedIcon = toggleButton.find('.sw-icon');
41
        expect(collapsedIcon.classes()).toContain('icon--regular-chevron-down-xs');
42
    });
43
44
    it('should be expanded', async () => {
45
        const wrapper = await createWrapper();
46
        await wrapper.setProps({
47
            isCollapsed: false,
48
        });
49
50
        const toggleButton = wrapper.find('.sw-cms-visibility-toggle__button');
51
        const collapsedIcon = toggleButton.find('.sw-icon');
52
53
        expect(collapsedIcon.classes()).toContain('icon--regular-chevron-up-xs');
54
    });
55
});
56