|
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
|
|
|
|