| Total Complexity | 8 |
| Complexity/F | 1 |
| Lines of Code | 61 |
| Function Count | 8 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { shallowMount } from '@vue/test-utils'; |
||
| 2 | import 'src/module/sw-cms/mixin/sw-cms-element.mixin'; |
||
| 3 | import 'src/module/sw-cms/elements/text/component'; |
||
| 4 | import 'src/module/sw-cms/elements/product-name/component'; |
||
| 5 | |||
| 6 | function createWrapper() { |
||
| 7 | return shallowMount(Shopware.Component.build('sw-cms-el-product-name'), { |
||
|
|
|||
| 8 | propsData: { |
||
| 9 | element: { |
||
| 10 | config: { |
||
| 11 | content: { |
||
| 12 | source: 'static', |
||
| 13 | value: null |
||
| 14 | }, |
||
| 15 | verticalAlign: { |
||
| 16 | source: 'static', |
||
| 17 | value: null |
||
| 18 | } |
||
| 19 | } |
||
| 20 | }, |
||
| 21 | defaultConfig: {} |
||
| 22 | }, |
||
| 23 | mocks: { |
||
| 24 | $sanitize: key => key |
||
| 25 | }, |
||
| 26 | data() { |
||
| 27 | return { |
||
| 28 | cmsPageState: { |
||
| 29 | currentPage: { |
||
| 30 | type: 'product_detail' |
||
| 31 | } |
||
| 32 | } |
||
| 33 | }; |
||
| 34 | }, |
||
| 35 | provide: { |
||
| 36 | cmsService: { |
||
| 37 | getPropertyByMappingPath: () => {} |
||
| 38 | } |
||
| 39 | }, |
||
| 40 | stubs: { |
||
| 41 | 'sw-text-editor': true |
||
| 42 | } |
||
| 43 | }); |
||
| 44 | } |
||
| 45 | |||
| 46 | describe('module/sw-cms/elements/product-name/component', () => { |
||
| 47 | let wrapper; |
||
| 48 | |||
| 49 | beforeEach(() => { |
||
| 50 | wrapper = createWrapper(); |
||
| 51 | }); |
||
| 52 | |||
| 53 | afterEach(() => { |
||
| 54 | wrapper.destroy(); |
||
| 55 | }); |
||
| 56 | |||
| 57 | it('should map to a product name if the component is in a product page', () => { |
||
| 58 | expect(wrapper.vm.element.config.content.source).toBe('mapped'); |
||
| 59 | expect(wrapper.vm.element.config.content.value).toBe('product.name'); |
||
| 60 | }); |
||
| 61 | }); |
||
| 62 |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.