1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
import { mount } from '@vue/test-utils';
import Toolbar from '~/vue_shared/components/markdown/toolbar.vue';
import EditorModeDropdown from '~/vue_shared/components/markdown/editor_mode_dropdown.vue';
describe('toolbar', () => {
let wrapper;
const createMountedWrapper = (props = {}) => {
wrapper = mount(Toolbar, {
propsData: { markdownDocsPath: '', ...props },
});
};
describe('user can attach file', () => {
beforeEach(() => {
createMountedWrapper();
});
it('should render uploading-container', () => {
expect(wrapper.vm.$el.querySelector('.uploading-container')).not.toBeNull();
});
});
describe('user cannot attach file', () => {
beforeEach(() => {
createMountedWrapper({ canAttachFile: false });
});
it('should not render uploading-container', () => {
expect(wrapper.vm.$el.querySelector('.uploading-container')).toBeNull();
});
});
describe('comment tool bar settings', () => {
it('does not show comment tool bar div', () => {
createMountedWrapper({ showCommentToolBar: false });
expect(wrapper.find('.comment-toolbar').exists()).toBe(false);
});
it('shows comment tool bar by default', () => {
createMountedWrapper();
expect(wrapper.find('.comment-toolbar').exists()).toBe(true);
});
});
describe('with content editor switcher', () => {
beforeEach(() => {
createMountedWrapper({
showContentEditorSwitcher: true,
});
});
it('re-emits event from switcher', () => {
wrapper.findComponent(EditorModeDropdown).vm.$emit('input', 'richText');
expect(wrapper.emitted('enableContentEditor')).toEqual([[]]);
});
});
});
|