Passed
Push — master ( c91dc3...4188a0 )
by Christian
14:57 queued 10s
created

src/Administration/Resources/app/administration/test/module/sw-settings-login-registration/page/sw-settings-login-registration.spec.js   A

Complexity

Total Complexity 9
Complexity/F 1

Size

Lines of Code 86
Function Count 9

Duplication

Duplicated Lines 25
Ratio 29.07 %

Importance

Changes 0
Metric Value
eloc 52
dl 25
loc 86
rs 10
c 0
b 0
f 0
wmc 9
mnd 0
bc 0
fnc 9
bpm 0
cpm 1
noi 1

1 Function

Rating   Name   Duplication   Size   Complexity  
A sw-settings-login-registration.spec.js ➔ createWrapper 0 49 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
import { createLocalVue, shallowMount } from '@vue/test-utils';
2
import 'src/module/sw-settings-login-registration/page/sw-settings-login-registration';
3
import 'src/module/sw-settings/component/sw-system-config';
4
5
const classes = {
6
    root: 'sw-page__main-content',
7
    cardView: 'sw-card-view',
8
    systemConfig: 'sw-system-config',
9
    settingsCard: 'sw-card'
10
};
11
12
function createWrapper() {
13
    Shopware.Feature.flags.FEATURE_NEXT_10555 = true;
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...
14
15
    const localVue = createLocalVue();
16
17
    return shallowMount(Shopware.Component.build('sw-settings-login-registration'), {
18
        localVue,
19
        mocks: {
20
            $tc: () => {},
21
            $route: {
22
                meta: {}
23
            }
24
        },
25
        provide: {
26
            feature: {
27
                isActive: () => true
28
            },
29
            systemConfigApiService: {
30
                getConfig: () => Promise.resolve({
31
                    'core.systemWideLoginRegistration.isCustomerBoundToSalesChannel': true
32
                })
33
            }
34
        },
35
        stubs: {
36
            'sw-page': {
37
                template: `
38
                     <div class="sw-page">
39
                          <slot name="smart-bar-actions"></slot>
40
                          <div class="sw-page__main-content">
41
                            <slot name="content"></slot>
42
                          </div>
43
                          <slot></slot>
44
                     </div>`
45
            },
46
            'sw-icon': true,
47
            'sw-card': {
48
                template: '<div class="sw-card"><slot></slot></div>'
49
            },
50
            'sw-card-view': {
51
                template: '<div class="sw-card-view"><slot></slot></div>'
52
            },
53
            'sw-button-process': true,
54
            'sw-system-config': Shopware.Component.build('sw-system-config'),
55
            'sw-search-bar': true,
56
            'sw-notification-center': true,
57
            'sw-loader': true
58
        }
59
    });
60
}
61
62 View Code Duplication
describe('module/sw-settings-login-registration/page/sw-settings-login-registration', () => {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
63
    let wrapper;
64
65
    beforeEach(() => {
66
        wrapper = createWrapper();
67
    });
68
69
    afterEach(() => {
70
        wrapper.destroy();
71
    });
72
73
    it('should be a Vue.js component', () => {
74
        expect(wrapper.vm).toBeTruthy();
75
    });
76
77
    it('should contain the settings card system', () => {
78
        expect(
79
            wrapper.find(`.${classes.root}`)
80
                .find(`.${classes.cardView}`)
81
                .find(`.${classes.systemConfig}`)
82
                .find(`.${classes.settingsCard}`)
83
                .exists()
84
        ).toBeTruthy();
85
    });
86
});
87
88