1
|
|
|
import { shallowMount, createLocalVue } from '@vue/test-utils'; |
2
|
|
|
import 'src/module/sw-mail-template/page/sw-mail-template-index'; |
3
|
|
|
|
4
|
|
|
const createWrapper = (privileges = []) => { |
5
|
|
|
const localVue = createLocalVue(); |
6
|
|
|
localVue.directive('tooltip', {}); |
7
|
|
|
|
8
|
|
|
return shallowMount(Shopware.Component.build('sw-mail-template-index'), { |
|
|
|
|
9
|
|
|
localVue, |
10
|
|
|
provide: { |
11
|
|
|
acl: { |
12
|
|
|
can: (identifier) => { |
13
|
|
|
if (!identifier) { return true; } |
14
|
|
|
|
15
|
|
|
return privileges.includes(identifier); |
16
|
|
|
} |
17
|
|
|
} |
18
|
|
|
}, |
19
|
|
|
mocks: { |
20
|
|
|
$tc: (translationPath) => translationPath, |
21
|
|
|
$route: { |
22
|
|
|
query: { |
23
|
|
|
page: 1, |
24
|
|
|
limit: 25 |
25
|
|
|
} |
26
|
|
|
}, |
27
|
|
|
$router: { |
28
|
|
|
replace: () => {} |
29
|
|
|
} |
30
|
|
|
}, |
31
|
|
|
stubs: { |
32
|
|
|
'sw-page': { |
33
|
|
|
template: ` |
34
|
|
|
<div class="sw-page"> |
35
|
|
|
<slot name="smart-bar-actions"></slot> |
36
|
|
|
<slot></slot> |
37
|
|
|
</div>` |
38
|
|
|
}, |
39
|
|
|
'sw-card-view': { |
40
|
|
|
template: '<div><slot></slot></div>' |
41
|
|
|
}, |
42
|
|
|
'sw-container': { |
43
|
|
|
template: '<div><slot></slot></div>' |
44
|
|
|
}, |
45
|
|
|
'sw-button': true, |
46
|
|
|
'sw-context-button': { |
47
|
|
|
template: ` |
48
|
|
|
<div class="sw-context-button"> |
49
|
|
|
<slot name="button"></slot> |
50
|
|
|
<slot></slot> |
51
|
|
|
</div>` |
52
|
|
|
}, |
53
|
|
|
'sw-context-menu-item': true, |
54
|
|
|
'sw-icon': true |
55
|
|
|
} |
56
|
|
|
}); |
57
|
|
|
}; |
58
|
|
|
|
59
|
|
|
describe('modules/sw-mail-template/page/sw-mail-template-index', () => { |
60
|
|
|
it('should not allow to create', () => { |
61
|
|
|
const wrapper = createWrapper(); |
62
|
|
|
|
63
|
|
|
const createButton = wrapper.find('.sw-context-button'); |
64
|
|
|
const innerButton = createButton.find('sw-button-stub'); |
65
|
|
|
|
66
|
|
|
expect(createButton.attributes().disabled).toBeTruthy(); |
67
|
|
|
expect(innerButton.attributes().disabled).toBeTruthy(); |
68
|
|
|
}); |
69
|
|
|
|
70
|
|
|
it('should allow to create', () => { |
71
|
|
|
const wrapper = createWrapper([ |
72
|
|
|
'mail_templates.creator' |
73
|
|
|
]); |
74
|
|
|
|
75
|
|
|
const createButton = wrapper.find('.sw-context-button'); |
76
|
|
|
const innerButton = createButton.find('sw-button-stub'); |
77
|
|
|
|
78
|
|
|
expect(createButton.attributes().disabled).toBeFalsy(); |
79
|
|
|
expect(innerButton.attributes().disabled).toBeFalsy(); |
80
|
|
|
}); |
81
|
|
|
}); |
82
|
|
|
|
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.