|
1
|
|
|
import { shallowMount, createLocalVue } from '@vue/test-utils'; |
|
2
|
|
|
import 'src/module/sw-cms/component/sw-cms-visibility-config'; |
|
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-config'), { |
|
13
|
|
|
localVue, |
|
14
|
|
|
propsData: { |
|
15
|
|
|
visibility: { |
|
16
|
|
|
mobile: true, |
|
17
|
|
|
tablet: true, |
|
18
|
|
|
desktop: true, |
|
19
|
|
|
} |
|
20
|
|
|
}, |
|
21
|
|
|
provide: { |
|
22
|
|
|
cmsService: {} |
|
23
|
|
|
}, |
|
24
|
|
|
stubs: { |
|
25
|
|
|
'sw-icon': await Shopware.Component.build('sw-icon'), |
|
26
|
|
|
'icons-regular-tablet': true, |
|
27
|
|
|
'icons-regular-mobile': true, |
|
28
|
|
|
'icons-regular-desktop': true, |
|
29
|
|
|
'icons-regular-tablet-slash': true, |
|
30
|
|
|
'icons-regular-mobile-slash': true, |
|
31
|
|
|
'icons-regular-desktop-slash': true, |
|
32
|
|
|
}, |
|
33
|
|
|
}); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
describe('module/sw-cms/component/sw-cms-visibility-config', () => { |
|
37
|
|
|
it('should be a Vue.js component', async () => { |
|
38
|
|
|
const wrapper = await createWrapper(); |
|
39
|
|
|
|
|
40
|
|
|
expect(wrapper.vm).toBeTruthy(); |
|
41
|
|
|
}); |
|
42
|
|
|
|
|
43
|
|
|
it('should be visible in all devices', async () => { |
|
44
|
|
|
const wrapper = await createWrapper(); |
|
45
|
|
|
const mobileIcon = wrapper.findAll('.sw-icon').at(0); |
|
46
|
|
|
expect(mobileIcon.classes()).toContain('icon--regular-mobile'); |
|
47
|
|
|
|
|
48
|
|
|
const tabletIcon = wrapper.findAll('.sw-icon').at(1); |
|
49
|
|
|
expect(tabletIcon.classes()).toContain('icon--regular-tablet'); |
|
50
|
|
|
|
|
51
|
|
|
const desktopIcon = wrapper.findAll('.sw-icon').at(2); |
|
52
|
|
|
expect(desktopIcon.classes()).toContain('icon--regular-desktop'); |
|
53
|
|
|
}); |
|
54
|
|
|
|
|
55
|
|
|
it('should be invisible in all devices', async () => { |
|
56
|
|
|
const wrapper = await createWrapper(); |
|
57
|
|
|
await wrapper.setProps({ |
|
58
|
|
|
visibility: { |
|
59
|
|
|
mobile: false, |
|
60
|
|
|
tablet: false, |
|
61
|
|
|
desktop: false, |
|
62
|
|
|
} |
|
63
|
|
|
}); |
|
64
|
|
|
|
|
65
|
|
|
const mobileIcon = wrapper.findAll('.sw-icon').at(0); |
|
66
|
|
|
expect(mobileIcon.classes()).toContain('icon--regular-mobile-slash'); |
|
67
|
|
|
|
|
68
|
|
|
const tabletIcon = wrapper.findAll('.sw-icon').at(1); |
|
69
|
|
|
expect(tabletIcon.classes()).toContain('icon--regular-tablet-slash'); |
|
70
|
|
|
|
|
71
|
|
|
const desktopIcon = wrapper.findAll('.sw-icon').at(2); |
|
72
|
|
|
expect(desktopIcon.classes()).toContain('icon--regular-desktop-slash'); |
|
73
|
|
|
}); |
|
74
|
|
|
}); |
|
75
|
|
|
|