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

src/Administration/Resources/app/administration/test/module/sw-cms/elements/product-name/sw-cms-el-product-name.spec.js   A

Complexity

Total Complexity 8
Complexity/F 1

Size

Lines of Code 61
Function Count 8

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 37
mnd 0
bc 0
fnc 8
dl 0
loc 61
rs 10
bpm 0
cpm 1
noi 1
c 0
b 0
f 0

1 Function

Rating   Name   Duplication   Size   Complexity  
A sw-cms-el-product-name.spec.js ➔ createWrapper 0 39 4
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'), {
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
                    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