Passed
Push — master ( f3221d...a39c0f )
by Christian
14:39 queued 11s
created

  B

Complexity

Conditions 4

Size

Total Lines 61
Code Lines 40

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 40
dl 0
loc 61
rs 8.92
c 0
b 0
f 0
cc 4

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

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/image/component';
4
import 'src/module/sw-cms/elements/manufacturer-logo/component';
5
6
function createWrapper() {
7
    return shallowMount(Shopware.Component.build('sw-cms-el-manufacturer-logo'), {
0 ignored issues
show
Bug introduced by
The variable Shopware seems to be never declared. If this is a global, consider adding a /** global: Shopware */ comment.

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.

Loading history...
8
        propsData: {
9
            element: {
10
                config: {
11
                    media: {
12
                        source: 'static',
13
                        value: null,
14
                        required: true,
15
                        entity: {
16
                            name: 'media'
17
                        }
18
                    },
19
                    displayMode: {
20
                        source: 'static',
21
                        value: 'cover'
22
                    },
23
                    url: {
24
                        source: 'static',
25
                        value: null
26
                    },
27
                    newTab: {
28
                        source: 'static',
29
                        value: true
30
                    },
31
                    minHeight: {
32
                        source: 'static',
33
                        value: null
34
                    },
35
                    verticalAlign: {
36
                        source: 'static',
37
                        value: null
38
                    }
39
                },
40
                data: {
41
                    media: ''
42
                }
43
            },
44
            defaultConfig: {}
45
        },
46
        data() {
47
            return {
48
                cmsPageState: {
49
                    currentPage: {
50
                        type: 'product_detail'
51
                    }
52
                }
53
            };
54
        },
55
        provide: {
56
            cmsService: {
57
                getCmsElementRegistry: () => {
58
                    return {};
59
                },
60
                getPropertyByMappingPath: () => {
61
                    return {};
62
                }
63
            }
64
        }
65
    });
66
}
67
68
describe('module/sw-cms/elements/manufacturer-logo/component', () => {
69
    let wrapper;
70
71
    beforeEach(() => {
72
        wrapper = createWrapper();
73
    });
74
75
    afterEach(() => {
76
        wrapper.destroy();
77
    });
78
79
    it('should map to a product manufacturer media if the component is in a product page', () => {
80
        expect(wrapper.vm.element.config.media.source).toBe('mapped');
81
        expect(wrapper.vm.element.config.media.value).toBe('product.manufacturer.media');
82
    });
83
});
84