Passed
Push — master ( c2902e...0ffee5 )
by Christian
12:32 queued 11s
created

src/Administration/Resources/app/administration/test/module/sw-product/component/sw-product-layout-assignment.spec.js   A

Complexity

Total Complexity 9
Complexity/F 1

Size

Lines of Code 48
Function Count 9

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A sw-product-layout-assignment.spec.js ➔ createWrapper 0 12 3
1
import { shallowMount } from '@vue/test-utils';
2
import 'src/module/sw-product/component/sw-product-layout-assignment';
3
4
function createWrapper() {
5
    return shallowMount(Shopware.Component.build('sw-product-layout-assignment'), {
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...
6
        mocks: {
7
            $t: key => key,
8
            $tc: key => key
9
        },
10
        stubs: {
11
            'sw-cms-list-item': true,
12
            'sw-button': true
13
        }
14
    });
15
}
16
17
describe('module/sw-product/component/sw-product-layout-assignment', () => {
18
    let wrapper;
19
20
    beforeEach(() => {
21
        wrapper = createWrapper();
22
    });
23
24
    afterEach(() => {
25
        wrapper.destroy();
26
    });
27
28
    it('should emit an event when openLayoutModal() function is called', () => {
29
        wrapper.vm.openLayoutModal();
30
31
        const pageChangeEvents = wrapper.emitted()['modal-layout-open'];
32
        expect(pageChangeEvents.length).toBe(1);
33
    });
34
35
    it('should emit an event when openInPageBuilder() function is called', () => {
36
        wrapper.vm.openInPageBuilder();
37
38
        const pageChangeEvents = wrapper.emitted()['button-edit-click'];
39
        expect(pageChangeEvents.length).toBe(1);
40
    });
41
42
    it('should emit an event when onLayoutReset() function is called', () => {
43
        wrapper.vm.onLayoutReset();
44
45
        const pageChangeEvents = wrapper.emitted()['button-delete-click'];
46
        expect(pageChangeEvents.length).toBe(1);
47
    });
48
});
49