blob: 8723fb5a338a368ac4682e09b2ac7fd10940e2e2 (
plain)
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
|
import { GlAlert } from '@gitlab/ui';
import { nextTick } from 'vue';
import { shallowMountExtended } from 'helpers/vue_test_utils_helper';
import ContentEditorError from '~/content_editor/components/content_editor_error.vue';
import EditorStateObserver from '~/content_editor/components/editor_state_observer.vue';
import { createTestEditor, emitEditorEvent } from '../test_utils';
describe('content_editor/components/content_editor_error', () => {
let wrapper;
let tiptapEditor;
const findErrorAlert = () => wrapper.findComponent(GlAlert);
const createWrapper = async () => {
tiptapEditor = createTestEditor();
wrapper = shallowMountExtended(ContentEditorError, {
provide: {
tiptapEditor,
},
stubs: {
EditorStateObserver,
},
});
};
afterEach(() => {
wrapper.destroy();
});
it('renders error when content editor emits an error event', async () => {
const error = 'error message';
createWrapper();
await emitEditorEvent({ tiptapEditor, event: 'error', params: { error } });
expect(findErrorAlert().text()).toBe(error);
});
it('allows dismissing the error', async () => {
const error = 'error message';
createWrapper();
await emitEditorEvent({ tiptapEditor, event: 'error', params: { error } });
findErrorAlert().vm.$emit('dismiss');
await nextTick();
expect(findErrorAlert().exists()).toBe(false);
});
});
|